ant + emma + junit
build.xml
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>
<?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>