Results 1 to 6 of 6
  1. #1
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default Why dosent my test run?!?

    I'm writting my first test case.
    Here's the code:
    Java Code:
    package test;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    
    import junit.framework.TestCase;
    import todo.DataManager;
    
    public class DataManagerTest extends TestCase {
    	
    	/*
    	 * Test that we get a arraylist
    	 */
    	public void getMessageTest(){
    		DataManager dm = new DataManager("test");
    		dm.setMessage("testtest");
    		assertTrue(!dm.getMessages().isEmpty());
    	}
    	
    	/*
    	 * Test setMessage
    	 */
    	public void setMessageTest(){
    		DataManager dm = new DataManager("test");
    		String message1 = "this is a text";
    		dm.setMessage(message1);
    		
    		String file = "tasks/test";
    		boolean isExist = false;
    		try{
    			//read file
    			BufferedReader br = new BufferedReader(new FileReader(file));    
               String line = null;
    			while((line = br.readLine()) != null) {
    				if(line == message1){
    					isExist = true;
    				}
    			}
    		}catch(IOException e){ e.getStackTrace(); }
    		
    		assertTrue(isExist == true);
    	}
    	
    	
    
    }
    First of if I started to write this test the first test(getMessageTest) did run successfully, but if I wrote the next one then it says "no tests found in tests.DataManagerTest", where is the problem?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    tests.DataManagerTest"
    vs
    package test;
    Wrong package/folder?

  3. #3
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    vs


    Wrong package/folder?

    sorry, my bad(typo)
    "no tests found in test.DataManagerTest"

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    Copy and paste vs typos and wasting time.

  5. #5
    ash_388235 is offline Member
    Join Date
    Aug 2010
    Posts
    1
    Rep Power
    0

    Default add @Test

    add @Test before method

    like


    @Test
    public voic someMethodTest(){

    }

  6. #6
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Quote Originally Posted by ash_388235 View Post
    add @Test before method

    like


    @Test
    public voic someMethodTest(){

    }
    Nope, problem still exists :S

Similar Threads

  1. Why dosent return new string
    By karq in forum New To Java
    Replies: 8
    Last Post: 08-04-2010, 08:51 AM
  2. why dosent the 2d array change?
    By TheBreadCat in forum New To Java
    Replies: 11
    Last Post: 05-15-2010, 01:20 PM
  3. Is it possible to test for NaN?
    By AJArmstron@aol.com in forum New To Java
    Replies: 7
    Last Post: 05-07-2010, 02:22 AM
  4. Replies: 0
    Last Post: 04-05-2008, 12:38 AM
  5. the code dosent work
    By pcman in forum Java 2D
    Replies: 1
    Last Post: 03-20-2008, 08:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •