Coverage---Cobertura



<!-- Coverage 1.7任务-->
<property name="cobertura.dir" value="${lib.dir}/three/coverage" />
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}">
<include name="cobertura.jar" />
<include name="lib/**/*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />


<target name="instrument">
<delete file="cobertura.ser"/>
<delete dir="${instrumented.dir}" />

<cobertura-instrument todir="${instrumented.dir}">
<fileset dir="${build.dir.main}">
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</fileset>
</cobertura-instrument>
</target>


<target name="coverage-report">
<cobertura-report destdir="${coverage.out}" srcdir="${src.main}" format="html"/>
</target>

<target name="Coverage" depends="compile,instrument,junit,coverage-report" />


<target name="test" depends="init,compile">
<junit fork="yes" dir="${basedir}" failureProperty="test.failed">
<!--
Note the classpath order: instrumented classes are before the
original (uninstrumented) classes. This is important.
-->
<classpath location="${instrumented.dir}" />
<classpath location="${classes.dir}" />

<!--
The instrumented classes reference classes used by the
Cobertura runtime, so Cobertura and its dependencies
must be on your classpath.
-->
<classpath refid="cobertura_classpath" />

<formatter type="xml" />
<test name="${testcase}" todir="${reports.xml.dir}" if="testcase" />
<batchtest todir="${reports.xml.dir}" unless="testcase">
<fileset dir="${src.dir}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>

<junitreport todir="${reports.xml.dir}">
<fileset dir="${reports.xml.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${reports.html.dir}" />
</junitreport>
</target>



注意点:
cobertura-1.7 --- jdk1.5
cobertura-1.9.4 --- jdk1.6(应该)


build.dir.main -- java编译后位置
coverage.out -- coverage输出位置
src.main -- 源码位置


三部曲:
instrument junit coverage-report

Junit中的重点
<classpath location="${instrumented.dir}" />
<classpath location="${classes.dir}" />
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值