当在ant中运行的JUnit测试失败时,如何记录完整的堆栈跟踪?
当JUnit测试在Eclipse中运行时引发运行时异常时,您可以看到整个堆栈跟踪当在ant中运行的JUnit测试失败时,如何记录完整的堆栈跟踪?,ant,junit,Ant,Junit,当JUnit测试在Eclipse中运行时引发运行时异常时,您可以看到整个堆栈跟踪 我们的构建服务器使用ant并运行JUnit,但是失败时的打印输出只提供异常消息,而不是整个“printStackTrace”。有没有一种方便的方法可以获得此功能?我在意识到这是你的一个副本之前,已经将此答案发布到了 这是我的junit标记,它确实生成异常跟踪 <junit showoutput="yes" errorProperty="test.failed" failureProperty="t
我们的构建服务器使用ant并运行JUnit,但是失败时的打印输出只提供异常消息,而不是整个“printStackTrace”。有没有一种方便的方法可以获得此功能?我在意识到这是你的一个副本之前,已经将此答案发布到了 这是我的junit标记,它确实生成异常跟踪
<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>
我认为一个嵌套元素可以为您完成这项工作
<formatter
type="brief"
usefile="false"
/>
JUnit BaseTestRunner中有一个限制此值的设置:
/**
* Truncates a String to the maximum length.
*/
public static String truncate(String s) {
if (fgMaxMessageLength != -1 && s.length() > fgMaxMessageLength)
s= s.substring(0, fgMaxMessageLength)+"...";
return s;
}
您可以通过设置来更改此值:
BaseTestRunner.setPreference("maxmessage", "-1");