Use configuration elements to exclude and include source files from being instrumented:
<configuration> ... <includes> <include>...ant style glob...</include> <include>**/specialpackage/*.java</include> </includes> <excludes> <exclude>**/*Dull.java</exclude> </excludes> </configuration>
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):
<configuration> ... <includesTestSourceRoots>false</includesTestSourceRoots> </configuration>
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 only.
To set this value in your pom.xml:
<configuration> <instrumentation>method</instrumentation> </configuration>
To set this value on the Maven command line:
-Dmaven.clover.instrumentation=method
The setting above will result in method level only instrumentation; no statement level coverage will be available.
Clover allows you to exclude coverage contexts from the coverage report.
To exclude try
bodies and static initialiser blocks:
<configuration> ... <contextFilters>try,static</contextFilters> </configuration>
To exclude arbitrary statements or methods you can specify one or more custom contexts like so:
<configuration> <methodContexts> <main>(.* )?public static void main\(String\[\] argv\).*</main> </methodContexts> <statementContexts> <log>System.out.println\(.*\);</log> <iflog>if.*\(LOG\.is.*\).*</iflog> <!-- NB: must match entire statement, including any semicolons. --> </statementContexts> </configuration>
*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:
<configuration> ... <contextFilters>main,log,iflog</contextFilters> </configuration>
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.
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:
<configuration> ... <jdk>1.4</jdk> </configuration>
You can set the Clover Flush Policy and interval:
<configuration> ... <flushPolicy>threaded</flushPolicy> <flushInterval>5000</flushInterval> </configuration>
To specify a particular location for your Clover database:
<configuration> ... <cloverDatabase>/foo/bar</cloverDatabase> </configuration>
and to set a location for the merged database:
<configuration> ... <cloverMergeDatabase>/foo/bar</cloverMergeDatabase> </configuration>
Do not set these locations explicitly if you have a multi-module project.