Configuring instrumentation

Controlling which source files are instrumented

Use configuration elements to exclude and include source files from being instrumented:

    <include>...ant style glob...</include>

Excluding tests from instrumentation

If you don't want to instrument your test classes, add the following to your pom.xml (note that this disables the reporting of per-test coverage as well as reporting of test results in Clover's HTML report):


Controlling the level of instrumentation

You can define the level that Clover will instrument to (and the respective performance overhead). Valid values are 'method' level (low overhead) or 'statement' level (high overhead). The default setting is 'statement'.

Setting this to 'method' greatly reduces the performance overhead of running Clover, however limited or no reporting is
available as a result. The typical use of the 'method' setting is:

  • for Test Optimization or
  • for projects with a large code base (as a rough estimate of coverage).

To set this value in your pom.xml:


To set this value on the Maven command line:


The setting above will result in method level only instrumentation; no statement level coverage will be available.

Configuring code contexts

Clover allows you to exclude coverage contexts from the coverage report.

To exclude try bodies and static initializer blocks:


To exclude arbitrary statements or methods you can specify one or more custom contexts like so:

    <main>(.* )?public static void main\(String\[\] argv\).*</main>
    <iflog>if.*\(LOG\.is.*\).*</iflog> <!-- NB: must match entire statement, including any semicolons. -->

*NB: A method context regexp must match the entire method signature. A statement context regexp must match the full statement, including the ';'.

Each one still needs to be 'enabled' via the <contextFilters/> element:


If you are filtering code from your coverage reports, you can keep track of what is filtered using the custom filteredElements column. See Creating custom reports for more information.

Setting JDK Level

In most cases Clover will autodetect the JDK you are using. If you are building with a 1.5 JDK but have set the maven-compiler-plugin's source and target parameters to use a JDK version of 1.4 you will need to set the Clover JDK level to 1.4:


Setting a Clover flush policy

You can set the Clover Flush Policy and interval:


Setting the Clover DB location

To specify a particular location for your Clover database:


and to set a location for the merged database:


We recommend to not use absolute paths if you have large multi-module projects. The point is that instead of having small databases for each module you will have one large database, being updated multiple times.

Last modified on Jul 14, 2016

Was this helpful?

Provide feedback about this article

Not finding the help you need?

Ask the community

Powered by Confluence and Scroll Viewport.