The <clover-check>
task 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.
属性 | 説明 | 必須 |
codeType | Since 3.1.6: Specifies which sources shall be taken for calculation. Valid values are: APPLICATION (business code), TEST (test code), ALL (business + test code). | No; Default value: APPLICATION. |
conditionalTarget | The target percentage conditional coverage for the project. | At least one of |
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). | いいえ。 |
filter | comma or space separated list of contexts to exclude when calculating coverage. See Using Coverage Contexts. | いいえ。 |
haltOnFailure | Specifies if the build should be halted if the target is not met. | No; default is " |
historydir | Allows you to specify a location for historical build data, along with a configurable threshold expressed as a percentage – used to cause the build to fail if coverage has dropped. This attribute is passed down to specified packages, then the same test is done for these at the package level. | No. Example: |
includeFailedTestCoverage | Specifies whether to include failed test coverage when calculating the total coverage percentage. | No; defaults to " |
initstring | The | No; If not specified here, Clover will look in the default location ( |
methodTarget | The target percentage method coverage for the project. | At least one of |
span | Specifies how far back in time to include coverage recordings from since the last Clover build. See Using Spans. | No; default includes "all coverage data found". |
statementTarget | The target percentage statement coverage for the project. | At least one of |
目標 | The target percentage total coverage for the project. e.g. " | At least one of |
Important note on target, methodTarget, statementTarget, conditionalTarget
Comparison of actual value with a target percentage is performed with such numerical precision as number of fractional digits set for a target percentage. A standard rounding is used (BigDecimal.ROUND_HALF_EVEN).
For example, if actual coverage value is 99.9% then for the target="100%" a build will pass, whereas for the target="100.000000%" a build will fail.
Specifies a target for a named package.
属性 | 説明 | 必須 |
---|---|---|
conditionalTarget | The target percentage conditional coverage for the package. | At least one of |
methodTarget | The target percentage method coverage for the package. | At least one of |
name | The name of the package. | Either (but not both) of |
regex | Regular expression to match package names. | Either (but not both) of |
statementTarget | The target percentage statement coverage for the package. | At least one of |
目標 | The target percentage total coverage for the package. e.g. "10%" | At least one of |
<testsources>
is an Ant fileset that can be used to distinguish test source code from application source code. All files included in the fileset will be displayed in the separate 'Test' node of the coverage tree. If omitted, Clover's default test detection algorithm will be used to distinguish test sources.
An optional Ant fileset containing a list of test result XML files.
<testresults>
is generally not required by most users, as the built-in test results will provide all required information in the majority of cases. For more details please see 'Advanced Usage'.
<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 if:
com.acme.killerapp.core
is at least 70%.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 doesn'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 ensures that the 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 at least 70%.