如何通过 Ant 显示 jUnit 错误 [英] How to Display jUnit Errors Via Ant
问题描述
我正在尝试将 Ant 脚本添加到我公司的项目中以运行 jUnit 测试.这是我所拥有的:
I am trying to add an Ant script to my company's project to run the jUnit tests. Here is what I have:
<target name="unit-tests">
<junit>
<classpath>
<pathelement location="${project.libext.dir}/junit-4.1.jar"/>
</classpath>
<batchtest>
<fileset dir="${project.src-test.dir}/my/company/." />
</batchtest>
</junit>
</target>
脚本正确地抓取了我的 jUnit 测试,但它说有错误.但所有输出都会说:
The script is grabbing my jUnit tests correctly, but it's saying there are errors. But all the output will say is things like:
[junit] Test package.MyTest FAILED
我想知道为什么它失败了.我曾尝试将一堆属性添加到 junit
标记(printsummary
、showoutput
等),但似乎找不到正确的组合.我设法得到的最好的是:
I want to know why it failed. I have tried adding a bunch of the attributes to the junit
tag (printsummary
, showoutput
, etc), but can't seem to find the right combination. The best I have managed to get is:
[junit] Running package.MyTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
我真的需要完整的堆栈跟踪等,因为当我 Run As > Junit Test via Eclipse 时测试运行良好.
I really need the full stack trace, etc as the test runs fine when I Run As > Junit Test via Eclipse.
有人知道如何打印堆栈跟踪吗?
Anyone know how to make the stack trace print?
推荐答案
找到了答案.需要添加格式化程序.
Found the answer. Needed to add a formatter.
<target name="unit-tests">
<junit>
<classpath>
<pathelement location="${project.libext.dir}/junit-4.1.jar"/>
</classpath>
<formatter type="plain" usefile="false" />
<batchtest>
<fileset dir="${project.src-test.dir}/my/company/." />
</batchtest>
</junit>
</target>
这篇关于如何通过 Ant 显示 jUnit 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!