【问题标题】:How can I get JUnit test (driven from Ant script) to dump the stack of exception that causes failure?如何让 JUnit 测试(从 Ant 脚本驱动)转储导致失败的异常堆栈?
【发布时间】:2011-01-29 14:59:38
【问题描述】:

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

<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

【问题讨论】:

标签: exception ant stack dump junit4


【解决方案1】:

在我看到this question 之前,我已经在这里发布了这个。我认为这个问题是重复的。

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

  <!-- #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"
  />

【讨论】:

    猜你喜欢
    • 2014-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-03
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    • 2012-03-11
    相关资源
    最近更新 更多