这个问题实际上很简单,但是之前也让我迷惑了一下。如果像我之前这篇日志里写的,如果在后面加上junitreport:
<junitreport>
<fileset dir="build/testoutput" includes="*.xml"/>
<report todir="build/testoutput"/>
</junitreport>
则只是生成xml格式的report,但是如果是在batchtest下面,如果所有的测试用例都执行完了,就会生成一系列的HTML报告,举例:
<target name="test"
depends="compile-tests"
description="Compile and execute the JUnit tests.">
<mkdir dir="build/testoutput"/>
<junit printsummary="on" fork="${test.fork}"
forkmode="once" showoutput="true"
failureproperty="junit.failure">
<jvmarg value="-XX:-UseSplitVerifier"/>
<classpath refid="allclasspath.path" />
<classpath>
<pathelement location="${build.dir}/test" />
</classpath>
<jvmarg value="-javaagent:lib\aspectjweaver-1.6.11.jar"/>
<batchtest todir="build/testoutput">
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<fileset dir="${build.dir}/test">
<include name="**/${test.class}.class" />
</fileset>
</batchtest>
</junit>
<junitreport>
<fileset dir="build/testoutput" includes="*.xml"/>
<report todir="build/testoutput"/>
</junitreport>
<fail if="junit.failure"
message="Unit tests failed. See build/testoutput/index.html" />
</target>
就这么点经验,总结一下。
本文探讨了在使用JUnit进行单元测试时,如何通过配置在测试完成后生成不同格式的报告,包括XML和HTML格式,以及如何在特定目标下实现这一过程。

1584

被折叠的 条评论
为什么被折叠?



