Code Coverage : EMMA and JUnit integrated by sadiquek7

VIEWS: 1,379 PAGES: 3

									<!-*************** Junit , EMMA integration @JUnit , EMMA integration ****************** !--> <project name="BuildCreation" default="runJunit" basedir="."> <!-====================================================================== -> <!-- EMMA SETUP --> <!-====================================================================== -> <property directory <property directory <property directory name="coverage.dir" value="${basedir}/reports/emma" /> which emma coverage reports will be written to --> name="instr.dir" value="${basedir}/target/emmainstr" /> which emma instrumentation classes will be written to --> name="emma.dir" value="${basedir}/lib/emma" /> that contains emma.jar and emma_ant.jar --> <!-<!-<!--

<!-- Set emma.lib to refer to the list of EMMA jar files --> <path id="emma.lib" > <fileset dir="${emma.dir}"> <include name="*.jar"/> </fileset> </path> <!-- Define which classes will be reported in the coverage reports (by default, we will include all classes and assume --> <!-- that your project's output folder is target/classes --> <path id="emma.coverage.classes" > <pathelement location="target/classes" /> </path> <path id="instr.classpath.path" > <pathelement location="${basedir}/target/emmainstr" /> </path> <!-- Load <emma> and <emmajava> custom tasks so that they can be used in ANT --> <taskdef resource="" classpathref="emma.lib" /> <!-- Enable Emma --> <target name="emma" description="turns on EMMA's instrumentation/reporting" > <property name="emma.enabled" value="true" /> <!-- EMMA instr class output directory (it is important to create this property only when EMMA is enabled) --> <mkdir dir="${instr.dir}" />

<!-- this property, if overriden via -Demma.filter=<list of filter specs> on ANT's command line, will set the coverage filter; by default, all classes found in 'emma.coverage.classes' pathref will be instrumented: --> <property name="emma.filter" value="" /> </target>

<target name="runJunit" description="Execute all junit tests" depends="emma"> <!-======================================================================= -> <!-- EMMA INSTRUMENTATION --> <!-======================================================================= -> <!-- Instrument the classes, this takes the normal classes, and makes instrumented classes instead --> <!-- Note that EMMA takes regular ANT path elements as instrumentation input, which is exceedingly convenient --> <emma enabled="${emma.enabled}" > <instr instrpathref="emma.coverage.classes" destdir="${instr.dir}" metadatafile="${coverage.dir}/metadata.emma" merge="true"> <!-<filter value="${emma.filter}" /> --> </instr> </emma> <junit> <classpath refid="instr.classpath.path" /> <formatter type="brief" usefile="false" /> <test name="ju.SocTest" /> <jvmarg value="Demma.coverage.out.file=${coverage.dir}/coverage.emma" /> <jvmarg value="-Demma.coverage.out.merge=true" /> </junit> <!-- if enabled, generate coverage report(s): --> <emma enabled="${emma.enabled}" > <report sourcepath="src" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100" > <!-- collect all EMMA data dumps (metadata and runtime) [this can be done via nested <fileset> fileset elements or <file> elements pointing to a single file]: --> <fileset dir="${coverage.dir}" > <include name="*.emma" />

</fileset> <fileset dir="${basedir}" > <include name="*.ec" /> </fileset> <!-- for every type of report desired, configure a nested element; various report parameters can be inherited from the parent <report> and individually overridden for each report type: --> <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> </target>


To top