Home | Clover | Clover.NET | FishEye | Support | Account | Download | Buy Now

Using Clover Interactively

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.

Clover provides the following features to support this development pattern:

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 initstring="clover-db/mycoverage.db">
     <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 initstring="clover-db/mycoverage.db">
     <files includes="${coverage.includes}"/>
  </clover-setup>

Developers can then use a command line like:

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

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.

The <clover-view> task launches the Swing coverage viewer which allows interactive browsing of coverage results:

  <clover-view/>
Note
If you launch the viewer from a second window, it can be left running while you develop. At the end of every test run, you can hit the "refresh" button on the viewer to load the latest coverage results.

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"/>