Skip to end of metadata
Go to start of metadata

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.


To ensure the coverage data is collected properly, make sure your tests run in (one or more) separate JVMs.

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:

  1. In the Code Coverage section, select JaCoCo as a coverage tool in the Choose coverage runner drop-down.
  2. Set up the coverage options - refer to the description of the available options below.




Classfile directories or jars

Newline-delimited set of path patterns in the form of +|-:[path] relative to the checkout directory to scan for classfiles to be analyzed. Libraries and test classfiles don't have to be listed unless their coverage is wanted.



Classes to instrument

Newline-delimited set of classname patterns in the form of +|-:[path]. Allows filtering out unwanted classes listed in "Classfile directories or jars" field. Useful in case test classes are compiled.



By default, in TeamCity the jacoco.sources property is set to "." , which means that TeamCity will scan whole checkout directory including all subdirectories for your sources.
Check that your classfiles are compiled with debug information (including the source file info) to see with highlighted source code in the report.

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


Default value



Space-delimited set of paths relative to the checkout directory to read the jacoco data file


jacocoResults/jacoco.exec jacocoResults/anotherJacocoRun.exec


Space-delimited set of classname include patterns


com.package.core.* com.package.api.*


Space-delimited set of classname exclude patterns


com.package.test.* .*Test


Space-delimited set of paths relative to the checkout directory to read sources from. Does not need to be listed by default.




Space-delimited set of path patterns in the form of +|-:[path] to scan for classfiles to be analyzed. Libraries and test classfiles do not need to be listed unless their coverage is wanted.




Path to the directory to store temporary files. The report will be generated as under this directory. Check that there is no existing directory with the same name.

A random directory under Agent's temp directory


An example of a complete service message:

  • No labels

1 Comment

  1. I found this doesn't work with Gradle 4.5. Here is my Gradle task:


    task uploadJacocoTestReport {
    doLast {
    println "##teamcity[jacocoReport dataPath='build/jacoco/jacocoTest.exec' " +
    "includes='*' " +
    "excludes='* " +
    "*' " +

    On TeamCity Gradle step, I invoke this and the coverage report does not appear on the Build Log page. This way used to work with Gradle 3.5 however. What do I need to change?