如何让 JUnit 测试(由 Ant 脚本驱动)转储导致失败的异常堆栈? [英] How can I get JUnit test (driven from Ant script) to dump the stack of exception that causes failure?

查看:21
本文介绍了如何让 JUnit 测试(由 Ant 脚本驱动)转储导致失败的异常堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们从 Ant 脚本运行 JUnit 测试,如下所示.当测试失败时,我希望它输出导致失败的异常的堆栈转储,但事实并非如此.有什么技巧可以让它倾倒吗?

We run JUnit test from Ant script, as follows. When the test failed, I expect it to output the stack dump of the exception that casuses the failure, but it doesn't. Is there any trick to get it dumped?

<target description="Run JUnit tests" name="run-junit" depends="build-junit">
    <copy file="./AegisLicense.txt" tofile="test/junit/classes/AegisLicense.txt" overwrite="true"/>
    <junit printsummary="yes" haltonfailure="no" fork="yes" forkmode="once" failureproperty="run-aegis-junit-failed" showoutput="yes" filtertrace="off">
        <classpath refid="Aegisoft.testsupport.classpath"/>
        <classpath>
            <pathelement location="test/junit/classes"/>
        </classpath>
        <batchtest>
            <fileset dir="test/junit/src">
                <include name="**"/>
            </fileset>
        </batchtest>
    </junit>
 <fail

推荐答案

在我看到 这个问题.我认为这个问题是重复的.

I've posted this here before I saw this question. I think this question is a duplicate.

这是我的 junit 标签,它确实产生了异常跟踪

Here is my junit tag that does produce the exception trace

  <!-- #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 测试(由 Ant 脚本驱动)转储导致失败的异常堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆