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>

 

testng emma 测试 覆盖率_第1张图片

你可能感兴趣的:(html,Web,xml,ant)