Help with code coverage using Sonar, Jacoco & Ant

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Help with code coverage using Sonar, Jacoco & Ant

This post has NOT been accepted by the mailing list yet.
Hi All,

I have followed these online samples on using sonar with ant and jacoco.

After updating the relevant sonar config parameters in the sample projects, the "sonar all" is working and sending over different metrics to sonar server.

But when I use the same configuration in our project with needed changes, the code coverage is not being captured. I have spent couple of days on this and unable to figure the issue. Any help is greatly appreciated.

Here are more details:

Attaching the build.xml for a single ant module in our project with needed changes. Also attached is the partial output I got after running "sonar all" on this module. I am just focusing on single module coverage before going to multi module project.

Besides other differences, the key differences in our project code from the samples are:

Some of the properties are already defined in parent build.properties file and hence I commented them out in the current modules build.xml
The compile, run-tests, init targets are also commented out as our project take care of these using different targets publish, test, etc in the parents build-commons.xml.
I made sure that the javac target has  fork="true" debug="true" artibutes set in the parent build file.

I am running this from a 32 bit ubuntu vm
$ ant -version
Apache Ant version 1.8.1 compiled on October 13 2010

One other different that should not make a difference is the name spacing. In the sample project, the src and test java files are right below the src and test folders. Like you expect we have a long list of name spaces in btw src and the actual file path is something like in ${basedir}/com/x/y/z/myjavafile.java. This is also true with test sources and the resulting class files structure.

I also specified sonar.jacoco.reportPath as in: <property name="sonar.jacoco.reportPath" value="jacoco.exec" />
Otherwise the default location the tool looks for the jacoco.exec is ${basedir}/target/ folder. We use ./build/ folder for our build files.

I am consistently getting this message "INFO o.s.p.j.JaCoCoPlugin - Project coverage is set to 0% as no JaCoCo execution data has been dumped: ${basedir}/jacoco.exec"

All other metrics are being collected fine except for code coverage numbers.

Also, <property name="sonar.jacoco.antTargets" value="run-tests" /> property seems to be not getting honored for my project as I don't see the junit xml file in the reports/junit directory.

Let me know if any other configuration details are needed.

Thanks for your help!!!