dcsimg
Problem with assertEquals(String,String)
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Pete_Cion
Posted On:   Thursday, December 7, 2006 04:48 PM

I am relatively new to junit, and am having a funky problem comparing two strings with the assertEquals method. Note that I can compare int's and Objects successfully, but junit is choking on Strings. In the code below, I am successfully executing the first two assertEquals, and having a problem (see below) on the third. hmmm. Any help here? Here is the source. Also, I'm using Junit 3.8.2 and Ant 1.6.5. Thanks for the help in advance. // p1 and px are two objects which I've set to be identical logger.info("about to assertEquals Object,Object (p1,px)"); assertEquals(p1, px); logger.info("after assertEquals Object,Object (p1,px)"); l   More>>

I am relatively new to junit, and am having a funky problem comparing two strings with the assertEquals method. Note that I can compare int's and Objects successfully, but junit is choking on Strings. In the code below, I am successfully executing the first two assertEquals, and having a problem (see below) on the third. hmmm. Any help here?


Here is the source. Also, I'm using Junit 3.8.2 and Ant 1.6.5. Thanks for the help in advance.



// p1 and px are two objects which I've set to be identical
logger.info("about to assertEquals Object,Object (p1,px)");


assertEquals(p1, px);


logger.info("after assertEquals Object,Object (p1,px)");


logger.info("about to assertEquals 1,1");


assertEquals(1, 1);


logger.info("after assertEquals 1,1");


logger.info("about to assertEquals (Y,Y)");


assertEquals("Test","Test");


logger.info("after assertEquals (Y,Y) ");



Here is the output of the ERROR from the third test:


[junit] ------------- ---------------- ---------------


[junit] Testcase: testGetProducts(tests.TestProductManager): Caused an ERROR


[junit]


junit.framework.TestCase.assertEquals(Ljava/lang/String;Ljava/lang/String;)V


[junit] at tests.TestProductManager.testGetProducts(TestProductManager.java:71)



Thanks in advance!

- Pete

   <<Less
About | Sitemap | Contact