Why no line number on junit failure?

Why no line number on junit failure?

Post by Roy Smit » Mon, 03 May 2004 07:58:37


I'm running junit under ant. One of my test cases is failing with
the following:

[junit] Testcase: testClassifyRecordType(FormatParserTest): FAILED
[junit] expected:<2> but was:<0>
[junit] junit.framework.AssertionFailedError: expected:<2> but was:<0>
[junit] at FormatParserTest.testClassifyRecordType(Unknown Source)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

I know the problem is in testClassifyRecordType, but I've got 2
different assertions in that test which expect the value 2. Why
doesn't the stack trace have enough information to give me the line
number it failed at?
 
 
 

Why no line number on junit failure?

Post by Christophe » Mon, 03 May 2004 08:23:52


[sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

Because you compiled FormatParserTest without debug information. Look
carefully at the ant task that compiles your classes.

--
Kind regards,
Christophe Vanfleteren

 
 
 

Why no line number on junit failure?

Post by Roy Smit » Mon, 03 May 2004 09:01:04

In article <ckWkc.93036$ XXXX@XXXXX.COM >,



Ah. That fixed it. Thanks!
 
 
 

Why no line number on junit failure?

Post by Tony Morri » Mon, 03 May 2004 12:35:27

> I know the problem is in testClassifyRecordType, but I've got 2

<javac debug="on>

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
 
 
 

Why no line number on junit failure?

Post by nospa » Mon, 03 May 2004 15:46:01


Most assertions allow for an optional message to further help describe
the test's intent. This is useful for situations like yours where you
have more than one assertion in a single test.

Pete