ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 5637] New: - NPE in JUnit XMLJunitResultFormatter if setUp() in TestSetup throws AssertionFailedError
Date Mon, 31 Dec 2001 11:49:18 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5637>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5637

NPE in JUnit XMLJunitResultFormatter if setUp() in TestSetup throws AssertionFailedError

           Summary: NPE in JUnit XMLJunitResultFormatter if setUp() in
                    TestSetup throws AssertionFailedError
           Product: Ant
           Version: 1.4.1
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Optional Tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: avik.sengupta@dresdner-bank.com


If one wraps a testcase using a junit.extensions.TestSetup (the idea being to 
run a set of setup routines only once for many fixtures) the 
XMLJunitResultFormatter throws an NPE if the setUp method of the TestSetup 
implementation class throws an  AssertionFailedError (or indeed any other 
throwable). 

Things are fine if the setUp method of a fixture (extending TestCase usually) 
throws an Exception. Problems occur only on a TestSetup wrapper. Also, the 
PlainTextFormatter works fine, only the xml formatter complains. 

the troublesome line is "currentTest.setAttribute(ATTR_TIME,...." in "public 
void endTest(Test test) {". Apparently currentTest is not populated when end 
test is called in such a scenario. I could send a patch saying "if 
(currentTest != null )......" but dont know enuf about how Junit task to be 
sure that'll work, or thats all thats reqd. 




[aviks@ra test]$ ant all-test
Buildfile: build.xml

all-test:
    [junit] Running AllTests

BUILD FAILED

java.lang.NullPointerException
        at 
org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter.endTest
(XMLJUnitResultFormatter.java:196)
        at 
org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter.formatError
(XMLJUnitResultFormatter.java:230)
        at 
org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter.addFailure
(XMLJUnitResultFormatter.java:207)
        at 
org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter.addFailure
(XMLJUnitResultFormatter.java:216)
        at junit.framework.TestResult.addFailure(TestResult.java:46)
        at junit.framework.TestResult.runProtected(TestResult.java:127)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run
(JUnitTestRunner.java:231)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM
(JUnitTask.java:582)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute
(JUnitTask.java:403)        at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute
(JUnitTask.java:380)        at org.apache.tools.ant.Task.perform(Task.java:217)
        at org.apache.tools.ant.Target.execute(Target.java:184)
        at org.apache.tools.ant.Target.performTasks(Target.java:202)
        at org.apache.tools.ant.Project.executeTarget(Project.java:601)
        at org.apache.tools.ant.Project.executeTargets(Project.java:560)
        at org.apache.tools.ant.Main.runBuild(Main.java:454)
        at org.apache.tools.ant.Main.start(Main.java:153)
        at org.apache.tools.ant.Main.main(Main.java:176)

Total time: 2 seconds

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message