如何让 ant 列出所有失败的 jUnit 测试?
我看过一些关于此问题的帖子,但没有一个提供我正在寻找的解决方案。我已经设置了 ant,所以当它运行我们的测试时,我们得到以下输出(我喜欢):
[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>
I've seen a couple of posts about this but none provide the solution I'm looking for. I have ant set up so when it runs our tests we get the following output (which I like):
[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 ...
But then at the end I just get "some tests failed". Is there some way to have it then list out the filenames of the tests that have failed?
thanks - dave
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读“使用 Ant 进行 Java 开发”的第 4 章: http://www.manning- source.com/books/hatcher/hatcher_ch04.pdf
您可以用来
生成测试的 xml 输出。使用 ant 任务 junitreport 运行所有测试后,可以将其转换为 html 以在浏览器中查看。如果使用的话也可以将xml文件导入到eclipse中。
Read chapter 4 of "Java Development with Ant": http://www.manning-source.com/books/hatcher/hatcher_ch04.pdf
You can use
to generate an xml output of the tests. This can be converted to html to view it in a browser after all tests have run using the ant task junitreport. You can also import the xml file into eclipse if you use it.