2
我见过一些关于此的帖子,但都没有提供我正在寻找的解决方案。我有蚂蚁成立,所以当它运行我们的测试中,我们得到如下输出(我喜欢):我如何拥有ant列表所有失败的jUnit测试?
[junit] Running net.windward.document.test.TestTab
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.59 sec
[junit] Running net.windward.document.test.TestTableAttributes
[junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.604 sec
... continues for 300+ tests ...
但随后在最后我只是得到“某些测试失败”。有什么方法可以列出失败的测试文件名吗?
谢谢 - 戴夫
的build.xml:
<junit printsummary="yes" errorProperty="test.failed" failureProperty="test.failed" >
<formatter type="plain" />
<classpath path="${classpath.run.test}"/>
<batchtest fork="yes" todir="${reports}">
<fileset dir="${src}">
<include name="**/test/**/Test*.java" />
<exclude name="**/_*/**/*.java" />
</fileset>
</batchtest>
</junit>
<fail if="test.failed" message="one or more unit tests failed"/>
<echo>unit tests all passed</echo>
<antcall target="testinternal"/>
</target>
我们尝试了这种方法 - 它仍列出所有测试,而不仅仅是失败的测试。另外,我们更愿意在控制台输出中获取列表 - 这样处理要快得多。谢谢 - dave –
查看http://ant.apache.org/manual/Tasks/junit.html的底部:使用另一个格式化程序类型“failure”应该生成一个Java TestCase,其中包含所有失败的测试,跑。虽然没有尝试过。缺点是你必须运行两次失败的测试。 – foowtf
您可以尝试扩展PlainJUnitResultFormatter,然后只写入失败的测试。 – foowtf