testng emma 测试 覆盖率

build.xml  testng测试 并生成覆盖率报告

<project name="coverage" default="emma.reports">

    <path id="emma.lib">
        <pathelement location="WebRoot/WEB-INF/lib/emma.jar" />
        <pathelement location="WebRoot/WEB-INF/lib/emma_ant.jar" />
    </path>

    <property file="build.properties" />
    <property name="reports" location="reports" />
    <property name="coverage" location="coverage" />
    <property name="coverage-output" location="coverage-classes" />
    <property name="output" location="classes" />

    <fileset dir="${JAVA_HOME}" />
    <fileset dir="${J2EE_HOME}" />

    <taskdef resource="testngtasks" classpath="WebRoot/WEB-INF/lib/testng-5.11-jdk15.jar" />
    <taskdef resource="emma_ant.properties" classpathref="emma.lib" />

    <path id="cp">
        <fileset dir="WebRoot/WEB-INF/lib">
            <include name="*.jar" />
        </fileset>
        <fileset dir="${JAVA_HOME}">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${J2EE_HOME}">
            <include name="**/*.jar" />
        </fileset>
        <pathelement location="${coverage-output}" />
        <pathelement location="${output}" />
    </path>
    <target name="compile">
        <mkdir dir="${output}" />
        <mkdir dir="${coverage-output}" />
        <javac source="1.5" srcdir="src" debug="true" destdir="${output}" classpathref="cp">
            <include name="**/*.java" />
        </javac>
    </target>
    <target name="emma" depends="compile">
        <emma>
            <instr instrpath="${output}"
                   destdir="${coverage-output}"
                   metadatafile="${coverage}/metadata.emma"
                   merge="true" />
        </emma>
    </target>
    <target name="coverage-test" depends="emma">
        <testng classpathref="cp">
            <classfileset dir="${coverage-output}" includes="**/*.class" />
            <jvmarg value="-Demma.coverage.out.file=${coverage}/coverage.emma" />
            <jvmarg value="-Demma.coverage.out.merge=true" />
        </testng>
    </target>
    <target name="emma.reports" depends="coverage-test">
        <emma>
            <report sourcepath="src">
                <fileset dir="${coverage}">
                    <include name="*.emma" />
                </fileset>
                <txt outfile="${reports}/coverage.txt" />
                <html outfile="${reports}/coverage.html" />
            </report>
        </emma>
    </target>
    <!--<target name="test" depends="compile">
        <testng classpathref="cp" suitename="ant">
            <classfileset dir="${output}" includes="**/*.class" />
        </testng>
    </target>-->
</project>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值