Reputation: 993
I am using Ant version 1.9.7 and JUnit 4.12. My build.xml looks like this:
<target name="run-junit" depends="init, compile, compile-junit">
<junit printsummary="yes" >
<formatter type="xml"/>
<classpath><pathelement location="lib/junit-4.12.jar"/></classpath>
<batchtest fork="yes" todir="${out.dir}">
<fileset dir="${bin.dir}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
</target>
When running ant run-junit
in a console it just gives me:
[junit] Running at.abc.def.ghi.ABCTest
[junit] Tests run: 5, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.065 sec
Test at.abc.def.ghi.ABCTest FAILED
But no more details. How can I resolve this?
Upvotes: 2
Views: 1203
Reputation: 7041
To get more details about each failed test, use <formatter type="plain" usefile="false"/>
instead of <formatter type="xml"/>
:
<junit printsummary="yes">
<formatter type="plain" usefile="false"/>
<classpath><pathelement location="lib/junit-4.12.jar"/></classpath>
<batchtest fork="yes" todir="${out.dir}">
<fileset dir="${bin.dir}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
Using a "plain" formatter gives output similar to the following:
[junit] Running TestMyTest1
[junit] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.014 sec
[junit]
[junit] Testcase: testMyTest took 0.003 sec
[junit] FAILED
[junit] expected:<firefox> but was:<null>
[junit] junit.framework.AssertionFailedError: expected:<firefox> but was:<null>
[junit] at TestMyTest1.testMyTest(TestMyTest1.java:17)
[junit]
[junit] Test TestMyTest1 FAILED
Upvotes: 2