JUnit+Ant什么时候可以生成HTML形式的report

本文探讨了在使用JUnit进行单元测试时,如何通过配置在测试完成后生成不同格式的报告,包括XML和HTML格式,以及如何在特定目标下实现这一过程。

这个问题实际上很简单,但是之前也让我迷惑了一下。如果像我之前这篇日志里写的,如果在后面加上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>

就这么点经验,总结一下。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值