|
The Maven 2 Clover plugin produces Clover reports from Maven 2 projects.
Maven Site Docs On this page:
Basic UsageTo use Clover with a Maven 2 project you will need to make a small change to your pom.xml.
For more license configuration options, see the FAQ pages. Checking a Coverage GoalYou can check that your test coverage has reached a certain threshold, and fail the build if it has not by adding a You can then use the clover2:check target to examine the Clover database and check that you have reached the coverage threshold. If you want the build to succeed anyway (printing a warning to your log), use the command line option Ratcheting Up CoverageClover can be configured to fail the build or warn you when the code coverage for a project drops relative to the previous build. The steps to configure the maven-clover2-plugin to do this are as follows:
You can also optionally specify a historyThreshold parameter which is the leeway used by clover2:check when comparing the coverage with the previous build. Configuring the PluginControlling which Source Files are InstrumentedUse configuration elements to exclude and include source files from being instrumented: Excluding your Tests from InstrumentationIf 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): Controlling the level of InstrumentationYou 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 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 ContextsClover allows you to exclude coverage contexts from the coverage report. To exclude To exclude arbitrary statements or methods you can specify one or more custom contexts like so: *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 If you are filtering code from your coverage reports, you can keep track of what is filtered using the custom Setting JDK LevelIn 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 PolicyYou can set the Clover Flush Policy and interval: Choosing Report FormatsThe Setting the Clover DB LocationTo specify a particular location for your Clover Database: and to set a location for the merged database: Do not set these locations explicitly if you have a multi-module project. Getting Information about your Clover DatabaseThe clover2:log goal will summarize your Clover database. Generating Historical ReportsTo include the generation of historical reports in your Clover reports, add the That will include your historical savepoints, if any, in the generated report. To generate a savepoint, run the clover2:save-history goal. To avoid having Creating Custom ReportsIt is now possible to define an external clover report descriptor file, the same way one can define a site.xml descriptor file. The descriptor file is basically a stripped down Ant file which will be run to produce the reports. All options available in clover-report can be specified. The default report descriptor used by the maven-clover2-plugin is: This is a very simple Ant file, which defines two known targets: "historical" and "current" . To change Clover's default reporting behavior, it is easiest to copy this file and add the changes you require. For a full list of clover-report elements and attributes, please consult the clover-report documentation. This file can be stored either on your local file system, or in your maven repository as a classified artifact. If stored on the file system, set this system property: or specify this element: in the If you wish to keep this descriptor in your maven repository you must specify this system property: or set this element: in the Properties for Custom ReportsA custom clover report descriptor can now access the standard Maven 2 properties. The following properties are available:
In addition to these properties, any additional properties defined in Working with Multimodule ProjectsYou can use the clover2:aggregate goal to combine the Clover databases of child projects into a single database at the parent project level. Because of this Maven bug, aggregation of databases occurs before the child databases have been generated, when you use the You can create Clover reports for a multimodule project with the command line Per-test coverage reporting is supported in Clover 2.1 onwards. Running Goals via
|
|
|
|
|
|






