我怎样才能获得JUnit测试(从Ant脚本驱动)转储异常堆栈导致失败呢? [英] How can I get JUnit test (driven from Ant script) to dump the stack of exception that causes failure?

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

问题描述

我们运行Ant脚本JUnit测试,如下所示。当测试失败了,我期望它输出casuses失败的异常堆栈转储,但事实并非如此。有没有办法把它甩的把戏?

 <目标描述=运行JUnit测试NAME =运行JUnit的依赖=集结JUnit的>
    <复制文件=./ AegisLicense.txtTOFILE =测试/ JUnit的/班/ AegisLicense.txt覆盖=真/>
    < JUnit的printsummary =YEShaltonfailure =NO叉=YESforkmode =曾经failureproperty =运行神盾的JUnit失败showoutput =YESfiltertrace =关>
        <类路径REFID =Aegisoft.testsupport.classpath/>
        <&类路径GT;
            < pathelement位置=测试/ JUnit的/班/>
        < /类路径>
        < batchtest>
            <文件集DIR =测试/ JUnit的/ src目录>
                <包括姓名=**/>
            < /文件集>
        < / batchtest>
    < / JUnit的>
 <失败


解决方案

我在这里张贴在此之前,我看到<一个href=\"http://stackoverflow.com/questions/2479877/how-to-get-full-stack-traces-logged-when-a-junit-test-running-in-ant-fails\">this问题。我认为这个问题是重复的。

这是我的junit标记,不产生异常跟踪
    
      
        
        
      

 &LT;! - 用于捕获和显示#Formatters  - &GT;
  &LT;格式化
    类型=简单
    usefile =假
  /&GT;
  &LT;格式化类型=简单/&GT;
  &LT;格式化
    键入=XML
    如果=test.generate.xml.output
  /&GT;  &LT;! - #TEST情况下隔离技术 - &GT;
  &lt;试验
    NAME =$ {}测试用例
    如果=测试用例
  /&GT;  &LT; batchtest
    todir =$ {} test.data.dir
    除非=测试用例
  &GT;
    &LT;文件集DIR =$ {} classes.dir&GT;
      &LT;包括姓名=** /测试的* .class/&GT;
      &LT;排除NAME =** /测试* $ *类/&GT;
    &LT; /文件集&GT;
  &LT; / batchtest&GT;&LT; / JUnit的&GT;

我认为这会为你做一个嵌套的元素是

 &LT;格式化
    类型=简单
    usefile =假
  /&GT;

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.

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天全站免登陆