ben*_*rre 16 java ant junit build-process
我在以下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>
Run Code Online (Sandbox Code Playgroud)
我如何告诉Junit输出每个测试的错误,以便我可以查看堆栈跟踪并调试问题.
Abd*_*ahC 17
您需要将formatter任务添加为batchtest任务的子项(而不是junit任务的直接子项)
formatter的语法是:
<formatter type="plain" usefile="false"/>
Run Code Online (Sandbox Code Playgroud)
type可以是一个plain,brief,xml或failure.
usefile="false" 要求Ant将输出发送到控制台.
在http://ant.apache.org/manual/Tasks/junit.html上向下滚动到"formatters"上的h4以获取更多详细信息.
答案是在标签内添加标签.
<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>
Run Code Online (Sandbox Code Playgroud)