Results 1 to 4 of 4
  1. #1
    sandor is offline Member
    Join Date
    Apr 2007
    Location
    Pennsylvania,USA
    Posts
    45
    Rep Power
    0

    Default TRying to use jUnit for Tesing

    I have this code and the test is just not working. Can anyone help me?
    Java Code:
    public class QueryBuilderTest extends TestCase {
    
    	
    	private String[] variablesChosen = new String[0];
    
    	
    	public void buildingPhenoTypeQuery() {
    		String[] displayItemsChosen = getDisplayItems();
    
    		QueryBuilder builder = new QueryBuilder();
    		String query = builder.buildPhenotypeQuery(displayItemsChosen);
    		String result = "from edu.iu.ms.ped.matrixweb.domain.Category cat where cat.displayOrder > 0  AND cat.phenoCat='Y' AND (cat.id in(66,68,70) OR cat.id in (select distinct(c.parent) from edu.iu.ms.ped.matrixweb.domain.Category c where c.id in(66,68,70))) order by cat.displayOrder";
    		assertNotNull(query);
    		assertEquals(query, result);
    	}
         private String[] getDisplayItems() {
    		String[] displayItemsChosen = new String[3];
    		displayItemsChosen[0] = "66";
    		displayItemsChosen[1] = "68";
    		displayItemsChosen[2] = "70";
    		return displayItemsChosen;
    	}
    }

  2. #2
    derrickD is offline Member
    Join Date
    Apr 2007
    Location
    USA
    Posts
    50
    Rep Power
    0

    Default

    When you are using junit , you must start each test method with the actual word "test". So, you method named "buildingPhenoTypeQuery" needs to be
    "testBuildingPhenoTypeQuery". Then it will work.

  3. #3
    goldhouse is offline Senior Member
    Join Date
    Mar 2007
    Posts
    134
    Rep Power
    0

    Default

    Not only test but it has to be " public void " also, Fortunately it is correct here

  4. #4
    derrickD is offline Member
    Join Date
    Apr 2007
    Location
    USA
    Posts
    50
    Rep Power
    0

    Default

    Since he already had public void I did not think there was any reason to mention it, snce that had nothing to do with why it was failing.

Similar Threads

  1. Junit
    By Azndaddy in forum New To Java
    Replies: 6
    Last Post: 06-15-2008, 07:47 AM
  2. Testing JUnit PDE with Ant
    By keynan in forum Eclipse
    Replies: 0
    Last Post: 02-15-2008, 12:35 AM
  3. Using Junit In Eclipse
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-06-2007, 04:41 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
  •