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 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 -DfailOnViolation=false
.
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 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.