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:

You can also optionally specify a historyThreshold parameter which is the leeway used by clover:check when comparing the coverage with the previous build. 

Last modified on Dec 8, 2015

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.