You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Wunderlich, Patrick" <Pa...@3SOFT.de> on 2005/10/21 12:57:15 UTC

[Junit] throws NullPointerException

Hey Ant users and friends!
 
I've a strange problem using the junit ant task.
Everything works fine, but when i add <formatter type="xml" />
i get following Exception:
 
    [junit] Exception in thread "main" java.lang.NullPointerException
    [junit]     at
org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter.for
matOutput(XMLJUnitResultFormatter.java:253)
    [junit]     at
org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter.set
SystemOutput(XMLJUnitResultFormatter.java:92)
    [junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.sendOutAndE
rr(JUnitTestRunner.java:435)
    [junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTe
stRunner.java:319)
    [junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUni
tTestRunner.java:672)
    [junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitT
estRunner.java:567)

=== code snippet form XMLJUnitResultFormatter ===

private void formatOutput(String type, String output) {
    Element nested = doc.createElement(type);
    rootElement.appendChild(nested);
    nested.appendChild(doc.createCDATASection(output));
}

=== code snippet form XMLJUnitResultFormatter ===
 
"doc" is null! There seems to be a problem with xml processing...
I've tested this with JDK 1.4.2_08 and 1.5.0_04 under WinXP.
Ant-Version: 1.6.5
 
Any hints?
 
Kind Regards,
Patrick Wunderlich (Germany)

Re: [Junit] throws NullPointerException

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 21 Oct 2005, Patrick Wunderlich <Pa...@3soft.de>
wrote:

> "doc" is null! There seems to be a problem with xml processing...
> I've tested this with JDK 1.4.2_08 and 1.5.0_04 under WinXP.
> Ant-Version: 1.6.5

Looks as if something in your testcase was writing to System.out
before Ant starts the tests.  A static block maybe?

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org