説明

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.

パラメーター

属性

説明

必須

目標

The target percentage total coverage for the project. e.g. "10%"

At least one of target, methodTarget, statementTarget or conditionalTarget is required, unless nested clover-check elements are specified.

methodTarget

The target percentage method coverage for the project.

At least one of target, methodTarget, statementTarget or conditionalTarget is required, unless nested clover-check elements are specified.

statementTarget

The target percentage statement coverage for the project.

At least one of target, methodTarget, statementTarget or conditionalTarget is required, unless nested clover-check elements are specified.

conditionalTarget

The target percentage conditional coverage for the project.

At least one of target, methodTarget, statementTarget or conditionalTarget is required, unless nested clover-check elements are specified.

initstring

The initstring of the coverage database.

No; If not specified here, Clover will look in the default location (${basedir}/.clover). If you have specified an initstring on the <clover-setup> task, you must ensure that <clover-setup> is called prior to 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).

いいえ。

filter

comma or space separated list of contexts to exclude when calculating coverage. See Using Coverage Contexts.

いいえ。

span

Specifies how far back in time to include coverage recordings from since the last Clover build. See Using Spans.

No; defaults to "0s".

includeFailedTestCoverage

Specifies whether to include failed test coverage when calculating the total coverage percentage.

No; defaults to "false".

Nested elements of <clover-check>

<package>

Specifies a target for a named package.

パラメーター

属性

説明

必須

name

The name of the package.

Either (but not both) of name or regex is required.

regex

Regular expression to match package names.

Either (but not both) of name or regex is required.

目標

The target percentage total coverage for the package. e.g. "10%"

At least one of target, methodTarget, statementTarget or conditionalTarget is required.

methodTarget

The target percentage method coverage for the package.

At least one of target, methodTarget, statementTarget or conditionalTarget is required.

statementTarget

The target percentage statement coverage for the package.

At least one of target, methodTarget, statementTarget or conditionalTarget is required.

conditionalTarget

The target percentage conditional coverage for the package.

At least one of target, methodTarget, statementTarget or conditionalTarget is required.

<testResults>

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:

  • 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 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%.