ant + emma + junit

build.xml

 

ContractedBlock.gif ExpandedBlockStart.gif Code
<?xml version="1.0"?>
<project name="Code coverage" default="all" basedir=".">
  
<target name="all" depends="compile, run" />

  
<property name="src.dir" value="${basedir}/src" />
  
<property name="out.dir" value="${basedir}/out" />
  
<property name="coverage.dir" value="${basedir}/coverage" />
  
<property name="emma.dir" value="${basedir}/lib" />

  
<path id="emma.lib" >
    
<pathelement location="${emma.dir}/emma.jar" />
    
<pathelement location="${emma.dir}/emma_ant.jar" />
  
</path>

  
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />

  
<target name="clean" description="resets this demo project to a clean state" >
    
<delete dir="${out.dir}" />
    
<delete dir="${basedir}/outinstr" />
    
<delete dir="${coverage.dir}" />
  
</target>

  
<target name="init" >
    
<delete dir="${coverage.dir}" />
    
<mkdir dir="${out.dir}" />
    
<path id="run.classpath" >
      
<pathelement location="${out.dir}" />
    
</path>
  
</target>

  
<target name="emma" >
    
<property name="emma.enabled" value="true" />
    
<property name="out.instr.dir" value="${basedir}/outinstr" />
    
<mkdir dir="${out.instr.dir}" />
    
<property name="emma.filter" value="-AllTests" />
  
</target>

  
<path id="build.classpath">
    
<fileset dir="${emma.dir}">
      
<include name="2_0_522.jar"/>
    
</fileset>
  
</path>

  
<target name="compile" depends="init" >
    
<javac debug="on" srcdir="${src.dir}" destdir="${out.dir}">
      
<classpath refid="build.classpath"/>
    
</javac>
  
</target>

  
<target name="run" depends="emma, init, compile" >
    
<emma enabled="${emma.enabled}" >
      
<instr instrpathref="run.classpath" destdir="${out.instr.dir}" metadatafile="${coverage.dir}/metadata.emma" merge="true" >
        
<filter value="${emma.filter}" />
      
</instr>
    
</emma>

    
<copy file="${out.dir}/AllTests.class" tofile="${out.instr.dir}/AllTests.class"/>

    
<junit printsummary="yes" haltonfailure="no" fork="yes" forkmode="perTest" showoutput="yes">
      
<jvmarg value="-Xmx1400m"/>
      
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
      
<jvmarg value="-Demma.coverage.out.merge=false" />

      
<classpath location="${out.instr.dir}"/>
      
<classpath refid="build.classpath"/>
      
<classpath refid="emma.lib"/>
      
<formatter type="xml"/>

      
<batchtest fork="yes" todir="${coverage.dir}">
        
<fileset dir="${out.instr.dir}">
          
<include name="*"/>
        
</fileset>
      
</batchtest>
    
</junit>

    
<emma enabled="${emma.enabled}" >
      
<report sourcepath="${src.dir}" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100" >
        
<fileset dir="${coverage.dir}" >
          
<include name="*.emma" />
        
</fileset>
        
<txt outfile="${coverage.dir}/coverage.txt" depth="package" columns="class,method,block,line,name" />
        
<xml outfile="${coverage.dir}/coverage.xml" depth="package" />
        
<html outfile="${coverage.dir}/coverage.html" depth="method" columns="name,class,method,block,line" />
      
</report>
    
</emma>

    
<delete dir="${out.dir}" />
    
<delete dir="${out.instr.dir}" />
    
<delete file="${coverage.dir}/coverage.emma" />
    
<delete file="${coverage.dir}/metadata.emma" />
    
<delete file="${coverage.dir}/TEST-AllTests.xml" />
    
<delete file="${coverage.dir}/coverage.txt" />
    
<delete file="${coverage.dir}/coverage.xml" />
  
</target>
</project>

转载于:https://www.cnblogs.com/aspxphpjsprb/archive/2009/10/23/1588411.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值