Ant JUnit 不显示失败的测试详细信息

Ant JUnit not showing failed test details

我使用的是 Ant 版本 1.9.7 和 JUnit 4.12。我的 build.xml 看起来像这样:

<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>

当 运行 ant run-junit 在控制台中时,它只给我:

[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

但没有更多细节。我该如何解决?

要获取有关每个失败测试的更多详细信息,请使用 <formatter type="plain" usefile="false"/> 而不是 <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>

使用 "plain" 格式化程序给出类似于以下内容的输出:

[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