JaCoCo
TeamCity supports JaCoCo, a Java Code Coverage tool allowing you to measure a wide set of coverage metrics and code complexity.
JaCoCo is available for the following build runners: Ant, IntelliJ IDEA Project, Gradle, and Maven.
TeamCity 2019.1 offers three bundled versions of JaCoCo:
0.7.5 (default)
0.8.2
0.8.4
On this page:
Enabling JaCoco coverage
TeamCity supports the java agent coverage mode allowing you to collect coverage without modifying build scripts or binaries. No additional build steps needed - just choose JaCoCo coverage in a build step which runs tests:
In the Code Coverage section, select JaCoCo as a coverage tool in the Choose coverage runner drop-down.
Set up the coverage options - refer to the description of the available options below.
Option | Description | Example |
---|---|---|
Classfile directories or jars | Newline-delimited set of path patterns in the form of |
|
Classes to instrument | Newline-delimited set of classname patterns in the form of |
|
The code coverage results can be viewed on the Overview tab of the Build Results page; detailed report is displayed on the dedicated Code Coverage tab.
Importing JaCoCo coverage data to TeamCity
TeamCity can parse JaCoCo coverage data and generate a report using a service message of the following format:
Attribute name | Description | Default value | Example |
---|---|---|---|
dataPath | Space-delimited set of paths relative to the checkout directory to read the jacoco data file |
| |
includes | Space-delimited set of classname include patterns |
|
|
excludes | Space-delimited set of classname exclude patterns |
| |
sources | Space-delimited set of paths relative to the checkout directory to read sources from. Does not need to be listed by default. |
|
|
classpath | Space-delimited set of path patterns in the form of |
|
|
reportDir | Path to the directory to store temporary files. The report will be generated as coverage | A random directory under Agent's temp directory | jacocoReport |
An example of a complete service message: