testng测试 并生成覆盖率报告

来源:互联网 发布:html javascript 编辑:程序博客网 时间:2024/05/17 22:41

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

Java代码  收藏代码
  1. <project name="coverage" default="emma.reports">  
  2.   
  3.     <path id="emma.lib">  
  4.         <pathelement location="WebRoot/WEB-INF/lib/emma.jar" />  
  5.         <pathelement location="WebRoot/WEB-INF/lib/emma_ant.jar" />  
  6.     </path>  
  7.   
  8.     <property file="build.properties" />  
  9.     <property name="reports" location="reports" />  
  10.     <property name="coverage" location="coverage" />  
  11.     <property name="coverage-output" location="coverage-classes" />  
  12.     <property name="output" location="classes" />  
  13.   
  14.     <fileset dir="${JAVA_HOME}" />  
  15.     <fileset dir="${J2EE_HOME}" />  
  16.   
  17.     <taskdef resource="testngtasks" classpath="WebRoot/WEB-INF/lib/testng-5.11-jdk15.jar" />  
  18.     <taskdef resource="emma_ant.properties" classpathref="emma.lib" />  
  19.   
  20.     <path id="cp">  
  21.         <fileset dir="WebRoot/WEB-INF/lib">  
  22.             <include name="*.jar" />  
  23.         </fileset>  
  24.         <fileset dir="${JAVA_HOME}">  
  25.             <include name="**/*.jar" />  
  26.         </fileset>  
  27.         <fileset dir="${J2EE_HOME}">  
  28.             <include name="**/*.jar" />  
  29.         </fileset>  
  30.         <pathelement location="${coverage-output}" />  
  31.         <pathelement location="${output}" />  
  32.     </path>  
  33.     <target name="compile">  
  34.         <mkdir dir="${output}" />  
  35.         <mkdir dir="${coverage-output}" />  
  36.         <javac source="1.5" srcdir="src" debug="true" destdir="${output}" classpathref="cp">  
  37.             <include name="**/*.java" />  
  38.         </javac>  
  39.     </target>  
  40.     <target name="emma" depends="compile">  
  41.         <emma>  
  42.             <instr instrpath="${output}"  
  43.                    destdir="${coverage-output}"  
  44.                    metadatafile="${coverage}/metadata.emma"  
  45.                    merge="true" />  
  46.         </emma>  
  47.     </target>  
  48.     <target name="coverage-test" depends="emma">  
  49.         <testng classpathref="cp">  
  50.             <classfileset dir="${coverage-output}" includes="**/*.class" />  
  51.             <jvmarg value="-Demma.coverage.out.file=${coverage}/coverage.emma" />  
  52.             <jvmarg value="-Demma.coverage.out.merge=true" />  
  53.         </testng>  
  54.     </target>  
  55.     <target name="emma.reports" depends="coverage-test">  
  56.         <emma>  
  57.             <report sourcepath="src">  
  58.                 <fileset dir="${coverage}">  
  59.                     <include name="*.emma" />  
  60.                 </fileset>  
  61.                 <txt outfile="${reports}/coverage.txt" />  
  62.                 <html outfile="${reports}/coverage.html" />  
  63.             </report>  
  64.         </emma>  
  65.     </target>  
  66.     <!--<target name="test" depends="compile">  
  67.         <testng classpathref="cp" suitename="ant">  
  68.             <classfileset dir="${output}" includes="**/*.class" />  
  69.         </testng>  
  70.     </target>-->  
  71. </project>  

 

0 0
原创粉丝点击