Install- Download undercover-${version}.jar. See http://undercover.googlecode.com/svn/maven/repository/undercover/undercover
- Download all dependencies. ASM and commons-lang.
- Instrument the classes by using the undercover-instrument task.
- Run test by using the junit task.
- Generate reports by using the undercover-report task.
Example: <path id="undercover.lib">
<pathelement location="${M2_REPO}/undercover/undercover/${undercover.version}/undercover-${undercover.version}.jar" />
<pathelement location="${M2_REPO}/asm/asm-all/3.2/asm-all-3.2.jar" />
<pathelement location="${M2_REPO}/commons-lang/commons-lang/2.4/commons-lang-2.4.jar" />
</path>
<taskdef resource="undercover-ant.properties" classpathref="undercover.lib" />
<undercover-instrument
destdir="${output}/undercover"
metadatafile="${output}/undercover/undercover.md">
<instrumentpath>
<pathelement location="${classes}" />
</instrumentpath>
<filter>
<include name="undercover/**" />
<exclude name="undercover/ISample" />
</filter>
</undercover-instrument>
<mkdir dir="${output}/undercover/test-report" />
<junit fork="yes" forkMode="once" haltonfailure="no">
<formatter type="plain" />
<classpath>
<pathelement location="${output}/undercover/classes" />
<pathelement location="${test-classes}" />
<path refid="test.dependencies" />
<path refid="compile.dependencies" />
<path refid="undercover.lib" />
</classpath>
<batchtest todir="${output}/undercover/test-report">
<fileset dir="${test-source}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
<sysproperty key="undercover.coveragedata.saveOnExit" value="true" />
<sysproperty key="undercover.coveragedata.file" value="${output}/undercover/undercover.cd" />
</junit>
<undercover-report
metadatafile="${output}/undercover/undercover.md"
coveragedatafile="${output}/undercover/undercover.cd"
sourceencoding="UTF-8">
<sourcepath>
<pathelement location="${source}" />
</sourcepath>
<html output="${output}/site/undercover" />
<emmaxml output="${output}/site/emma/coverage.xml" />
<coberturaxml output="${output}/site/cobertura/coverage.xml" />
</undercover-report>TasksInstrument TaskParametersAttributes| Attribute | Description | Required | | destdir | The location to store instrumented class files. | Yes | | metadatafile | The location to store metadata. Default is file undercover.md in the current directory. | No |
Nested Elements| Element | Description | Required | | instrumentpath | A path-like structure that specifies the instrumentation path to use. | Yes | | filter | A patternset that specifies classes to be instrumented. | No |
Report TaskParametersAttributes| Attribute | Description | Required | | metadatafile | The location to load metadata. Default is file undercover.md in the current directory. | No | | coveragedatafile | The location to load coverage data. Default is file undercover.cd in the current directory. | No | | sourceencoding | Encoding of the source files. Default is the default charset of this Java virtual machine. | No |
Nested Elements| Element | Description | Required | | sourcepath | A path-like structure that specifies the source path to use. | No | | html | Instructs to generate an HTML report. | No | | emmaxml | Instructs to generate an Emma compatible XML report. | No | | coberturaxml | Instructs to generate an Cobertura compatible XML report. | No |
|