如何获得当JUnit测试运行中的蚂蚁失败记录完整的堆栈踪迹? [英] How to get full stack traces logged when a JUnit test running in ant fails?
问题描述
在JUnit测试抛出一个运行时异常在Eclipse中运行时,可以看到整个堆栈跟踪。
When a JUnit test throws a runtime exception while running in Eclipse, you can see the entire stack trace.
我们的构建服务器使用Ant和JUnit的运行,但失败的打印输出只提供异常的信息,而不是整个的printStackTrace。有没有一种方便的方式来获得此功能?
Our build server uses ant and runs JUnit, but the printout on failure only provides the exception's message, not the entire "printStackTrace". Is there a convenient way to get this functionality?
推荐答案
我已经张贴了这个答案,<一个href=\"http://stackoverflow.com/questions/2480151/how-can-i-get-junit-test-driven-from-ant-script-to-dump-the-stack-of-exception\">this意识到这是你的一个重复之前的问题。
I've posted this answer to this question before realizing that it was a duplicate of yours.
这是我的junit标记,不产生异常跟踪。
Here is my junit tag that does produce the exception trace.
<junit
showoutput="yes"
errorProperty="test.failed"
failureProperty="test.failed"
haltOnFailure="${test.halt-on-failure}"
fork="yes"
forkmode="${junit.forkmode}"
>
<classpath>
<pathelement location="${classes.dir}"/>
<pathelement location="${classes-under-test.classes.dir}" />
</classpath>
<!-- #Formatters for capture and display -->
<formatter
type="brief"
usefile="false"
/>
<formatter type="brief" />
<formatter
type="xml"
if="test.generate.xml.output"
/>
<!-- #Test case isolation technique -->
<test
name="${testcase}"
if="testcase"
/>
<batchtest
todir="${test.data.dir}"
unless="testcase"
>
<fileset dir="${classes.dir}">
<include name="**/Test*.class" />
<exclude name="**/Test*$*.class" />
</fileset>
</batchtest>
</junit>
我认为这会为你做一个嵌套的元素是
I think the one nested element that will do it for you is
<formatter
type="brief"
usefile="false"
/>
这篇关于如何获得当JUnit测试运行中的蚂蚁失败记录完整的堆栈踪迹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!