Home | Forums

<clover-check>

Description

Tests project/package code coverage against criteria, optionally failing the build if the criteria are not met. This task needs to be run after coverage has been recorded.

Parameters

Attribute Description Required
target The target percentage total coverage for the project. e.g. "10%" At least one of these, unless nested <package> elements are specified.
methodTarget The target percentage method coverage for the project.
statementTarget The target percentage statement coverage for the project.
conditionalTarget The target percentage conditional coverage for the project.
initstring The initstring of the coverage database. No; If not specified here, you must ensure <clover-setup> is called prior the execution of this task.
haltOnFailure Specifies if the build should be halted if the target is not met. No; default is "false"
failureProperty Specifies the name of a property to be set if the target is not met. If the target is not met, the property will contain a text description of the failure(s). No
filter comma or space separated list of contexts to exclude when calculating coverage. See Using Contexts. No
span Specifies how far back in time to include coverage recordings from since the last Clover build. See Using Spans. No; Defaults to "0s".

Nested elements of <clover-check>

<package>

Specifies a target for a named package.

Parameters
Attribute Description Required
name The name of the package. exactly one of these
regex Regular expression to match package names.
target The target percentage total coverage for the package. e.g. "10%" At least one of these.
methodTarget The target percentage method coverage for the package.
statementTarget The target percentage statement coverage for the package.
conditionalTarget The target percentage conditional coverage for the package.

Examples

 <clover-check target="80%"/>

Tests if total percentage coverage is at least 80%. If not, a message is logged and the build continues.

 <clover-check target="80%"
              haltOnFailure="true"/>

Tests if total percentage coverage is at least 80%. If not, a message is logged and the build fails.

 <clover-check target="80%"
              failureProperty="coverageFailed"/>

Tests if total percentage coverage is at least 80%. If not, a message is logged and the project property coverageFailed is set.

 <clover-check target="80%"
    <package name="com.acme.killerapp.core" target="70%"/>
    <package name="com.acme.killerapp.ai" target="40%"/>
 </clover-check>

Tests:

  • total percentage coverage for project is at least 80%
  • total percentage coverage for package com.acme.killerapp.core is at least 70%
  • total percentage coverage for package com.acme.killerapp.ai is at least 40%

If any of these criteria are not met, a message is logged and the build continues.

 <clover-check target="80%"
              filter="catch">
    <package name="com.acme.killerapp.core" target="70%"/>
    <package name="com.acme.killerapp.ai" target="40%"/>
 </clover-check>

As above, but don't include coverage of catch blocks when measuring criteria.

 <clover-check target="80%" conditionalTarget="90%"
              filter="catch">
    <package name="com.acme.killerapp.core" target="70%"/>
    <package name="com.acme.killerapp.ai" target="40%"/>
 </clover-check>

As previous example, but also ensure project conditional coverage is at least 90%.

 <clover-check>
    <package regex="com.acme.killerapp.core.*" target="70%"/>
 </clover-check>

Tests if coverage for com.acme.killerapp.core and all subpackages is atleast 70%.