This is the documentation for Clover 3.3. View this page for the

Unknown macro: {spacejump}

of Clover, or visit the latest Clover documentation.

In this scenario, a developer is responsible for obtaining a certain level of code coverage on her code before it is accepted into the base.

The typical cycle the developer follows is something like:

  1. write code/tests
  2. run tests
  3. inspect test results and code coverage

This process is repeated until all tests pass and code coverage of the tests meets a certain level.

Measuring coverage on a subset of source files

The <clover-setup> task takes an optional nested fileset element that tells Clover which files should be included/excluded in coverage analysis:

<clover-setup>
     <files includes="**/plugins/cruncher/**, **/plugins/muncher/**"/>
</clover-setup>

The includes could be set using an Ant property so that individual developers can specify includes on the command line:

<property name="coverage.includes" value="**"/>
  <clover-setup>
     <files includes="${coverage.includes}"/>
  </clover-setup>

Developers can then use a command line like the following for Java code:

ant build -Dcoverage.includes=java/**/foo/*.java

And for Groovy code:

ant build -Dcoverage.includes=groovy/**/foo/*.groovy

Viewing source-level code coverage quickly

Clover provides two ways of quickly viewing coverage results. The <clover-log> task provides quick reporting to the console:

<clover-log/>

The output format from the <clover-log> task uses the [file:line:column] format that many IDEs can parse.

Viewing summary coverage results quickly

The <clover-log> task provides an option that will print a summary of coverage results to the console:

<clover-log level="summary"/>

Incrementally building coverage results

When iteratively improving coverage on a subset of your project, you may want to include coverage data from several iterations in coverage results. Clover supports this with the span attribute which works on current reports — see Using Spans. This attribute can be used to tell Clover how far back in time to include coverage results (measured from the time of the last Clover build). To include results gathered over the last hour use:

<clover-log span="1h"/>