JaCoCo coverage not working

I've enabled the jacoco coverage feature in my ant build on the TC server.  I don't see the Code Coverage tab after the build runs.  Any thoughts would be much appreciated.

I see the following in my build log:

Here is the resulting jacoco.log:

Jacoco report builder run with arguments: [-dataPaths, '/home/ci/buildAgent/temp/buildTmp/JACOCO8526525118464185903coverage/jacoco.exec', -sr, '.', -cp, '+:build/**/*.class +:dist/**/*.class', -i, '*', -rd, '/home/ci/buildAgent/temp/buildTmp/JACOCO8526525118464185903coverage/report', -t, 'Build Pipeline', -l, 'true']
Exec files loaded in: 384
Filter set up with includes: *; excludes: <none>
Classfiles read in: 122
Info headers read in: 0
Creating SourceCodeFinder from .
Source files read in: 485
Report written in: 1142
Jacoco report builder exits normally

Here is the resulting coverage.params file:

#Thu Jul 17 13:13:25 MDT 2014
teamcity.coverage.jacoco.classpath=+\:build/**/*.class +\:dist/**/*.class
Comment actions Permalink


Parameters look correctly. Please make sure that the paths to classes are valid and also that your tests run in the fork=true mode.

Comment actions Permalink

I've been able to make some headway on this issue.

I'm now getting the report to generate and show up on TeamCity.  However, the report seems to be missing some of my test classes.  I say this because I have unit tests that exercise various src classes that are not showing up as being covered on the report.  Here's what I've defined as my Classfile directories or jars value:


I've verified that the test classes I'm compiling are indeed within a test-classes directory.  Thoughts?

The weirdest part of this issue is that other test classes in the same directory and package are showing up on the report.  For example, given the following:







I see the com.foo package and results for com.foo.Foo, but not com.foo.Bar.

Comment actions Permalink

Could you please attach jacoco.log, jacoco.exec (hidden artifacts) and build log files?

Comment actions Permalink

These tips are proving helpful.  I'm seeing a lot of the following:

java.io.IOException: Error while analyzing class /home/ci/depot/./other-agent-root/prj/product/foo/dist/classes/com/foobar/MyClass.class.
    at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:150)
Caused by: java.lang.IllegalStateException: Can't add different class with same name: com/foobar/MyClass
    at org.jacoco.core.analysis.CoverageBuilder.visitCoverage(CoverageBuilder.java:106)
    ... 6 more

I believe this is due to a failure to exclude certain directories from the jacoco classpath.  Specifically, I'm attempting to exclude the other-agent-root directory with the following: -:**/other-agent-root/**/*.class

Here's a snippet of my jacoco.log:

Jacoco report builder run with arguments: [-dataPaths, '/home/ci/buildAgent/temp/buildTmp/JACOCO7616972526584307278coverage/jacoco.exec', -sr, '.', -cp, '+:**/build/main/**/*.class +:**/classes/**/*.class -:**/build/test/**/*.class -:**/test-classes/**/*.class -:**/other-agent-root/**/*.class', -i, '*', -e, 'com.red.* com.orange.* com.blue.*', -rd, '/home/ci/buildAgent/temp/buildTmp/JACOCO7616972526584307278coverage/report', -t, 'Build Pipeline', -l, 'true']
Exec files loaded in: 388
Filter set up with includes: *; excludes: com.red.* com.orange.* com.blue.*

Comment actions Permalink

It's a known issue - http://youtrack.jetbrains.com/issue/TW-36758, which have been already fixed. Please upgrade to TeamCity 8.1.4.

Comment actions Permalink

So is my exclusion pattern incorrect or not working due to this bug?

Comment actions Permalink

It is due to this bug. As workaround you can exclude classes with the same names.


Please sign in to leave a comment.