You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2002/01/01 02:07:16 UTC
DO NOT REPLY [Bug 5637] -
NPE in JUnit XMLJunitResultFormatter if setUp() in TestSetup throws AssertionFailedError
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
------- Additional Comments From jakarta@ehatchersolutions.com 2001-12-31 17:07 -------
I've looked into this issue (downloading your attachment and have duplicated
it). JUnit's TestResult class (which is what TestCase's use to run with) calls
startTest right away, but the TestSetup class used in your example does not
(TestSetup's run method calls setUp prior to calling startTest on the
listener). I'm not sure if this is a JUnit flaw or not, but its certainly an
interesting and perhaps tricky issue.
I've made a small patch:
public void endTest(Test test) {
Element currentTest = (Element) testElements.get(test);
if (currentTest == null) { // <-- NEW
startTest(test); // <-- NEW
currentTest = (Element) testElements.get(test); // <-- NEW
} // <-- NEW
Long l = (Long) testStarts.get(test);
currentTest.setAttribute(ATTR_TIME,
""+((System.currentTimeMillis()-l.longValue())
/ 1000.0));
}
Which caused the test to run (and fail) as expected with this in the XML
results:
<testcase name="unknown" time="0.0">
<failure message="Throw error in Global Setup" type="junit.framework.Asserti
onFailedError">junit.framework.AssertionFailedError: Throw error in Global Setup
at AllTests$1.setUp(AllTests.java:19)
at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
at junit.extensions.TestSetup.run(TestSetup.java:23)
</failure>
</testcase>
Although notice that the testcase name is "unknown". Why is that?
Anyway, if this patch seems harmless enough then I will apply it, but I want to
get some other committer (Stephane?) feedback before doing so.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>