No information about coverage by test

Hi,

SonarQube, 6.7.5.38563
Code Analyzer for Java * 5.7 (build 15470) installed

I have setup for jacoco in pom.xml

I first execute:

mvn -P coverage clean test

and I file is produced under:

…/target/jacoco.exec

Then I run:

mvn sonar:sonar -P sonar4 -Dsonar.report.export.path=sonar-report.json -Dsonar.issuesReport.json.enable=true

From the log I can find:

[INFO] Sensor FindBugs Sensor [findbugs] (done) | time=13069ms
[INFO] Sensor SurefireSensor [java]
[INFO] parsing [/repo/eraonel/git/mje-custom-java-rules/target/surefire-reports]
[INFO] Sensor SurefireSensor [java] (done) | time=90ms
[INFO] Sensor JaCoCoSensor [java]
[INFO] Analysing /repo/eraonel/git/mje-custom-java-rules/target/jacoco.exec
[INFO] No information about coverage per test.
[INFO] Sensor JaCoCoSensor [java] (done) | time=396ms

Do you know what the reason could be for this?

br,

//mikael

Hi, What is the issue exactly ?
the logs tell you that you won’t have information about which test covered which lines. This is a deprecated feature (as documented in https://docs.sonarqube.org/display/PLUG/Usage+of+JaCoCo+with+SonarJava ). You get this information because you did not configured the junit listener so this is expected as far as I can tell.

Ok I did not know that it was deprecated. But now I know. Thx for informing me
:blush:

br,

//mikael

1 Like

Hi Nicolas,

I have the same problem as @eraonel here who started this thread. I am able to get all the coverage information except Coverage per Test which you have mentioned above, that it is deprecated.
I read another thread on this forum which was dated this year and the person could successfully get the information on what tests covered particular line of code by clicking on the green bar on the side.

I would really like this information in my sonarqube project.

I am using the following:
sonarqube-6.7.6
sonar-scanner-cli-3.2.0.1227.jar
jacocoant.jar from jacoco v0.8.2

The unit tests are run as part of an Ant build.
I have wrapped the junit tests with jacoco coverage tags:

<jacoco:coverage enabled="{coverage.enabled}" destfile="{jacoco.dir}/steps_jacoco.report">

  <junit maxmemory="1024M"
                   fork="true"
                   forkmode="perBatch"
                   haltonfailure="false"
                   failureproperty="tests.failed"
        		   printsummary="withOutAndErr"
                   showoutput="true">

                <formatter type="xml" />

                <classpath>
                    <path refid="additional-junit-classpath" />
                    <fileset refid="fileset:third-party_jars-for-tests" />
                    <pathelement path="${project.build.dir}/acceptanceTest-classes" />
                    <pathelement path="${project.build.dir}/test-classes" />
                    <pathelement path="${project.build.dir}/../core/test-classes" />
                </classpath>
                <batchtest todir="${test.result.dir}">
                    <fileset dir="${project.build.dir}/../core/acceptanceTest-classes">
                        <include name="**/blah.class" />
                        <include name="**/blah.class" />
                    </fileset>
                    <fileset dir="${project.build.dir}/acceptanceTest-classes">
                        <include name="**/*Test.class" />
                        <exclude name="**/blah.class" />
                    </fileset>
                </batchtest>
   </junit>

</jacoco:coverage>

The jacoco report is successfully created after running the Ant build with the above code.
After this I run the sonar-scanner on a linux environment using the following command line command:

sonar-scanner -Dproject.settings=$locationOfPropertyFile

image

Some properties from the sonarqube.properties file:

sonar.junit.reportPaths={env.blah}/test-results sonar.java.coveragePlugin=jacoco sonar.surefire.reportsPath={env.blah}/test-results
sonar.jacoco.reportPaths=${env.blah}/jacoco_steps_report/steps_jacoco.report

Is there anyway I can get the coverage per test information?
Your help with be highly appreciated :slight_smile:

Regards,
Dhawal