JaCoCo configuration for source directory

In the configuration of JaCoCo code coverage section (Ant build step), I can configure:

  • Class file directories
  • Classes to instrument

but not able to configure the source directory and therefore the report does not show the line coverage report.

Looking into my coverage.params file, I can see the property defaulted to "." and I would want to have it "./src":

teamcity.coverage.jacoco.sources=.

Looked into the documentation but it does not mention anything on how to configue it. Not found any reported bug on you issue tracker.


TC version used: 9.0.5

Thanks for your help.
M

6 comments
Comment actions Permalink

I think you don't need a source directory.
We use it something like this:

for "Classfile directories or jars" %some_project_specific_path%/jar/*.jar
for "Classes to instrument"  com.companyName.*

0
Comment actions Permalink

Thanks for your reply. Perhaps I wasn't clear enough.

I am able to generate the basic JaCoCo coverage report but ideally I would like to see the link to my source code highlighted, e.g.:

http://www.eclemma.org/jacoco/trunk/coverage/org.jacoco.examples/org.jacoco.examples/ExecDump.java.html#L52

From the JaCoCo documentation:

sourcefiles
: Optional container element for Ant resources and     resource collections that specify corresponding source files. If source     files are specified, some report formats include highlighted source code.     Source files can be specified as individual files or as source directories.

http://www.eclemma.org/jacoco/trunk/doc/ant.html


It is not a showstopper but would be nice to be able to drill down.

0
Comment actions Permalink

Do you compile the source code with debugging information? (Attribute "debug" of the ant javac task)

0
Comment actions Permalink

Hi Marcos,

By default in TeamCity "jacoco.sources" property is set to "." which means that TeamCity will scan whole checkout directory (including all subdirectories - with "src/' in your case) for your sources. So the report should be generated with highlighted source code if coverage is collected properly. Please check that your classfiles are compiled with debug info (including source file info) and check .teamcity/coverage_jacoco/jacoco.log for problems.

You could also try IDEA coverage runner

0
Comment actions Permalink

Thanks!  Correct answer.

I was not using the debug="on" to compile my classes. Changed it and everything works like a charm now.

0
Comment actions Permalink

Spasiva Adrey.

>>By default in TeamCity "jacoco.sources" property is  set to "." which means that TeamCity will scan whole checkout directory  (including all subdirectories - with "src/' in your case) for your  sources.
Very thorough answer. I wish this sentece would have been in the TC wiki page when I was having the issue :)  it would have really helped me. Thanks!

0

Please sign in to leave a comment.