JaCoCo - jacoco:check

# jacoco:check

Full name:

org.jacoco:jacoco-maven-plugin:0.6.3.201306030806:check

Description:

Checks that the code coverage metrics are being met.

Attributes:

- Requires a Maven project to be executed.
- The goal is thread-safe and supports parallel builds.
- Binds by default to the lifecycle phase: `verify`.

## Required Parameters

Name | Type | Since | Description
haltOnFailure | `boolean` | `-` | Halt the build if any of the checks fail. Default value is: `true`.
rules | `List` | `-` | Check configuration used to specify rules on element types (BUNDLE, PACKAGE, CLASS, SOURCEFILE or METHOD) with a list of limits. Each limit applies to a certain counter (INSTRUCTION, LINE, BRANCH, COMPLEXITY, METHOD, CLASS) and defines a minimum or maximum for the corresponding value (TOTALCOUNT, COVEREDCOUNT, MISSEDCOUNT, COVEREDRATIO, MISSEDRATIO). If a limit refers to a ratio the range is from 0.0 to 1.0 where the number of decimal places will also determine the precision in error messages. This example requires an overall instruction coverage of 80% and no class must be missed:
    <rules>
      <rule>
        <element>BUNDLE</element>
        <limits>
          <limit>
            <counter>INSTRUCTION</counter>
            <value>COVEREDRATIO</value>
            <minimum>0.80</minimum>
          </limit>
          <limit>
            <counter>CLASS</counter>
            <value>MISSEDCOUNT</value>
            <maximum>0</maximum>
          </limit>
        </limits>
      </rule>
    </rules>
This example requires a line coverage minimum of 50% for every class except test classes:
    <rules>
      <rule>
        <element>CLASS</element>
        <excludes>
          <exclude>*Test</exclude>
        </excludes>
        <limits>
          <limit>
            <counter>LINE</counter>
            <value>COVEREDRATIO</value>
            <minimum>0.50</minimum>
          </limit>
        </limits>
      </rule>
    </rules>

## Optional Parameters

Name | Type | Since | Description
dataFile | `File` | `-` | File with execution data. Default value is: `${project.build.directory}/jacoco.exec`.
excludes | `List` | `-` | A list of class files to exclude from instrumentation/analysis/reports. May use wildcard characters (* and ?). When not specified nothing will be excluded.
includes | `List` | `-` | A list of class files to include in instrumentation/analysis/reports. May use wildcard characters (* and ?). When not specified everything will be included.
skip | `boolean` | `-` | Flag used to suppress execution. Default value is: `false`.

## Parameter Details

dataFile:

File with execution data.

- Type: `java.io.File`
- Required: `No`
- Default: `${project.build.directory}/jacoco.exec`

excludes:

A list of class files to exclude from instrumentation/analysis/reports. May use wildcard characters (* and ?). When not specified nothing will be excluded.

- Type: `java.util.List`
- Required: `No`

haltOnFailure:

Halt the build if any of the checks fail.

- Type: `boolean`
- Required: `Yes`
- Expression: `${jacoco.haltOnFailure}`
- Default: `true`

includes:

A list of class files to include in instrumentation/analysis/reports. May use wildcard characters (* and ?). When not specified everything will be included.

- Type: `java.util.List`
- Required: `No`

rules:

Check configuration used to specify rules on element types (BUNDLE, PACKAGE, CLASS, SOURCEFILE or METHOD) with a list of limits. Each limit applies to a certain counter (INSTRUCTION, LINE, BRANCH, COMPLEXITY, METHOD, CLASS) and defines a minimum or maximum for the corresponding value (TOTALCOUNT, COVEREDCOUNT, MISSEDCOUNT, COVEREDRATIO, MISSEDRATIO). If a limit refers to a ratio the range is from 0.0 to 1.0 where the number of decimal places will also determine the precision in error messages.

This example requires an overall instruction coverage of 80% and no class must be missed:

    <rules>
      <rule>
        <element>BUNDLE</element>
        <limits>
          <limit>
            <counter>INSTRUCTION</counter>
            <value>COVEREDRATIO</value>
            <minimum>0.80</minimum>
          </limit>
          <limit>
            <counter>CLASS</counter>
            <value>MISSEDCOUNT</value>
            <maximum>0</maximum>
          </limit>
        </limits>
      </rule>
    </rules>

This example requires a line coverage minimum of 50% for every class except test classes:

    <rules>
      <rule>
        <element>CLASS</element>
        <excludes>
          <exclude>*Test</exclude>
        </excludes>
        <limits>
          <limit>
            <counter>LINE</counter>
            <value>COVEREDRATIO</value>
            <minimum>0.50</minimum>
          </limit>
        </limits>
      </rule>
    </rules>

- Type: `java.util.List`
- Required: `Yes`

skip:

Flag used to suppress execution.

- Type: `boolean`
- Required: `No`
- Expression: `${jacoco.skip}`
- Default: `false`