Question

We are using Sonar Ant Runner to report project statistics. We collect existing report files after the ant-build ran all tests and calculated coverage using JaCoCo. So we use "reuseReports" in our properties, see below.

Now what happens is that the tests run fine, JaCoCo captures coverage fine, the JaCoCo coverage report itself looks sane, but Sonar only displays a few classes in the coverage section, many classes are missing.

The other sections like unit tests, violations, debt, ... look ok, only coverage is wrong.

The build-file looks something like this, we use the pre-2.0 compatible format because we have many libs defined as ant-Properties and we did not yet convert these to the sonar.libraries=... format:

    ....
<property name="sonar.dynamicAnalysis" value="reuseReports" />
<property name="sonar.sourceEncoding" value="UTF-8" />
<property name="sonar.projectVersion" value="2.0" />

<!-- surefire will become junit in some version of Sonar -->
<property name="sonar.surefire.reportsPath" value="report" />
<property name="sonar.junit.reportsPath" value="report" />

<property name="sonar.jacoco.reportPath" value="merged.exec" />

<!-- Add the target -->
<target name="sonar" depends="mergecoverage">
    <echo message="Running Sonar analysis" />

    <sonar:sonar key="${sonar.projectKey}" version="2.0" xmlns:sonar="antlib:org.sonar.ant">

         <sources>...</sources>

        <tests>...</tests>

        <binaries>...</binaries>

        <libraries>...</libraries>
    </sonar:sonar>
</target>

It seems there is not much more logging I can turn on, any clue why Sonar is only displaying coverage for a few classes?

Was it helpful?

Solution

I actually found the solution myself: it seems it was caused by a bug in the sonar-jacoco-plugin. Version 1.2 had a bug so that it only included the first binary directory.

This is fixed in version 1.3 of the sonar-jacoco-plugin.

See http://jira.codehaus.org/browse/SONARJAVA-164 for details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top