Output labels each test as 'unknown'
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Larry_Hannay
Posted On:   Sunday, September 3, 2006 10:50 AM

Here is output from a class containing two simple JUnit tests. (I am using JUnit 4.1 and chopped off most of the stack trace output.) One passes and one fails. Testcase: unknown took 0.015 sec Caused an ERROR whatever expected: <0> but was: <1> java.lang.AssertionError: whatever expected: <0> but was: <1> at org.junit.Assert.fail(Assert.java:69) at org.junit.Assert.failNotEquals(Assert.java:314) at org.junit.Assert.assertEquals(Assert.java:94) at cart.CartTest.whatever(CartTest.java:95) Testcase: unknown took 0.016 sec Why are the test cases labeled 'unknown'? Wouldn't it be more helpful to give the name of the test met   More>>

Here is output from a class containing two simple JUnit tests. (I am using JUnit 4.1 and chopped off most of the stack trace output.) One passes and one fails.


			
Testcase: unknown took 0.015 sec
Caused an ERROR
whatever expected: <0> but was: <1>
java.lang.AssertionError: whatever expected: <0> but was: <1>
at org.junit.Assert.fail(Assert.java:69)
at org.junit.Assert.failNotEquals(Assert.java:314)
at org.junit.Assert.assertEquals(Assert.java:94)
at cart.CartTest.whatever(CartTest.java:95)

Testcase: unknown took 0.016 sec


Why are the test cases labeled 'unknown'? Wouldn't it be more helpful to give the name of the test method, which would be

getTotal
for the example below? Is there a way to do this?


			
@Test
public void getTotal()
{
assertEquals("Bad cart total",
prod1Count * prod1Price + prod2Count * prod2Price,
cart.getTotal(),
0.01); // delta for floating point comparison);
}


Thanks,
Larry

   <<Less
About | Sitemap | Contact