Getting stack trace on *simple* failure
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Larry_Hannay
Posted On:   Thursday, August 31, 2006 10:59 AM

Hi, I'm using JUnit 4.1 in eclipse 3.1.2 with ant 1.6.5. I've set up my first tests and finally got them running. The problem is that I'm getting a stack trace dumped on a very simple error. Here is the one test that fails: @Test public void whatever() { assertEquals("whatever", 1, 0); } Here is the output: [junit] Testsuite: cart.CartTest [junit] Tests run: 2, Failures: 0, Errors: 1, Time elapsed: 0.031 sec [junit] Testcase: unknown took 0.016 sec [junit] Caused an ERROR [junit] whatever expected: <1> but was: <0> [junit] java.lang.AssertionError: whatever expected: &   More>>

Hi,

I'm using JUnit 4.1 in eclipse 3.1.2 with ant 1.6.5.


I've set up my first tests and finally got them running. The problem is that I'm getting a stack trace dumped on a very simple error.


Here is the one test that fails:

			
@Test
public void whatever()
{
assertEquals("whatever", 1, 0);
}

Here is the output:
			
[junit] Testsuite: cart.CartTest
[junit] Tests run: 2, Failures: 0, Errors: 1, Time elapsed: 0.031 sec
[junit] Testcase: unknown took 0.016 sec
[junit] Caused an ERROR
[junit] whatever expected: <1> but was: <0>
[junit] java.lang.AssertionError: whatever expected: <1> but was: <0>
[junit] at org.junit.Assert.fail(Assert.java:69)
[junit] at org.junit.Assert.failNotEquals(Assert.java:314)
[junit] at org.junit.Assert.assertEquals(Assert.java:94)
[junit] at cart.CartTest.whatever(CartTest.java:71)
[junit] at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
[junit] at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
[junit] at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
[junit] at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
[junit] at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
[junit] at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
[junit] at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
[junit] at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
[junit] at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
[junit] at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
[junit] at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)
[junit] Testcase: unknown took 0 sec

Why am I getting a stack trace? Am I missing something or doing something wrong?


Thanks,

Larry

   <<Less

Re: Getting stack trace on *simple* failure

Posted By:   Anonymous  
Posted On:   Thursday, September 14, 2006 11:18 AM

JUnit doesn't know (or care) whether the error is simple or not and therefore provides you with as much information as you may need to resolve the issue.
About | Sitemap | Contact