简体   繁体   English

Junit Ant Task,输出堆栈跟踪

[英]Junit Ant Task, output stack trace

I have a number of tests failing in the following JUnit Task. 我在以下JUnit任务中有许多测试失败。

 <target name="test-main" depends="build.modules" description="Main Integration/Unit tests">
        <junit fork="yes"
               description="Main  Integration/Unit Tests"
               showoutput="true"
               printsummary="true"
               outputtoformatters="true">
            <classpath refid="test-main.runtime.classpath"/>
            <batchtest filtertrace="false" todir="${basedir}">
                <fileset dir="${basedir}" includes="**/*Test.class" excludes="**/*MapSimulationTest.class"/>
            </batchtest>
        </junit>
    </target>

How do I tell Junit to ouput the errors for each test so that I can look at the stack trace and debug the issues. 我如何告诉Junit输出每个测试的错误,以便我可以查看堆栈跟踪并调试问题。

You'll need to add the formatter task as a child of the batchtest task (NOT as the immediate child of the junit task) 您需要将formatter任务添加为batchtest任务的子项(而不是junit任务的直接子项)

The syntax of formatter is: formatter的语法是:

<formatter type="plain" usefile="false"/>

type can be one of plain , brief , xml or failure . type可以是plainbriefxmlfailure

usefile="false" asks Ant to send output to the console. usefile="false"要求Ant将输出发送到控制台。

Scroll down to the h4 on "formatters" at http://ant.apache.org/manual/Tasks/junit.html for more details. http://ant.apache.org/manual/Tasks/junit.html上向下滚动到“formatters”上的h4以获取更多详细信息。

The answer was to add the tag within the tag. 答案是在标签内添加标签。

 <target name="test-main" depends="build.modules" description="Main Integration/Unit tests">
        <junit fork="yes"
               description="Main  Integration/Unit Tests"
               showoutput="true"
               printsummary="true"
               outputtoformatters="true">
            <classpath refid="test-main.runtime.classpath"/>
            <batchtest filtertrace="false">
                <fileset dir="${basedir}/out/test/common" includes="**/*Test.class" excludes="**/*MapSimulationTest.class"/>
                <fileset dir="${basedir}/out/test/test-simulation" includes="**/*Test.class" excludes="**/*MapSimulationTest.class"/>
            </batchtest>
            <formatter type="brief" usefile="false"/>
        </junit>
    </target>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM