如何显示错误的JUnit通过Ant [英] 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 <的/ code>,等),但似乎无法找到合适的组合。我设法得到的最好的是:
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
我真的需要完整的堆栈跟踪等作为测试运行正常,当我运行方式>通过Eclipse的JUnit测试。
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>
这篇关于如何显示错误的JUnit通过Ant的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!