Configuring a coverage goal
Setting coverage threshold as a quality gate
You can check that your test coverage has reached a certain threshold, and fail the build if it has not by adding a targetPercentage
tag to your plugin configuration in pom.xml
:
<configuration>
...
<targetPercentage>75%</targetPercentage>
...
</configuration>
You can then use the clover: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 -DfailOnViolation=false
.
Ratcheting Up Coverage
Clover 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 clover-maven-plugin
to do this are as follows:
- specify the clover:historyDir configuration for clover:check
- save a history point using the clover:save-history goal at report time. This will be used by the subsequent build.
You can also optionally specify a historyThreshold parameter which is the leeway used by clover:check when comparing the coverage with the previous build.