Java Junit Ant任务,输出堆栈跟踪
在下面的JUnit任务中,我有许多测试失败Java Junit Ant任务,输出堆栈跟踪,java,ant,build-process,junit,Java,Ant,Build Process,Junit,在下面的JUnit任务中,我有许多测试失败 <target name="test-main" depends="build.modules" description="Main Integration/Unit tests"> <junit fork="yes" description="Main Integration/Unit Tests" showoutput="true"
<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>
如何告诉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">
<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>
您需要将格式化程序任务添加为batchtest任务的子任务(而不是junit任务的直接子任务) 格式化程序的语法为:
<formatter type="plain" usefile="false"/>
类型
可以是普通
、简短
、xml
或故障
中的一种
usefile=“false”
要求Ant将输出发送到控制台
向下滚动到位于的“formatters”(格式化程序)上的h4以了解更多详细信息。至少在ant 1.9.0中,您还可以将格式化程序添加为junit任务的子任务。如果您有多个批处理任务,这将非常有用。