Code Coverage reports are not getting reflected on sonarqube dashboard

I am using Sonarqube Enterprise Edition Version 7.9.1 (build 27448)
I am having the scoverage.xml report generated using command:

mvn verify sonar:sonar

getting output as:

Run completed in 2 minutes, 39 seconds.
Total number of tests run: 10
Suites: completed 5, aborted 0
Tests: succeeded 10, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
[INFO]
[INFO] <<< scoverage-maven-plugin:1.4.1:report (default) < [scoverage]test @ ccr-reporting <<<
[INFO]
[INFO] --- scoverage-maven-plugin:1.4.1:report (default) @ ccr-reporting ---
[INFO] Reading scoverage instrumentation [/mrit_cm2/rawasum/ds-rfds-falconnet/falcon-agents/dispatcher-tasks/ccr-reporting/target/scoverage-data/scoverage.coverage]...
[INFO] Reading scoverage measurements [/mrit_cm2/rawasum/ds-rfds-falconnet/falcon-agents/dispatcher-tasks/ccr-reporting/target/scoverage-data/scoverage.measurements.*]...
[INFO] Generating coverage reports...
[INFO] Written Cobertura XML report [/mrit_cm2/rawasum/ds-rfds-falconnet/falcon-agents/dispatcher-tasks/ccr-reporting/target/cobertura.xml]
[INFO] Written XML coverage report [/mrit_cm2/rawasum/ds-rfds-falconnet/falcon-agents/dispatcher-tasks/ccr-reporting/target/scoverage.xml]
[INFO] Written HTML coverage report [/mrit_cm2/rawasum/ds-rfds-falconnet/falcon-agents/dispatcher-tasks/ccr-reporting/target/site/scoverage/index.html]
[INFO] Statement coverage.: 36.07%
[INFO] Branch coverage....: 6.25%
[INFO] Coverage reports completed.

And analysis is also successfull:

[INFO] 5 files to be analyzed
[INFO] 5/5 files analyzed
[INFO] Calculating CPD for 13 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 151ms, dir size=384 KB
[INFO] Analysis report compressed in 100ms, zip size=127 KB
[INFO] Analysis report uploaded in 244ms
[INFO] ANALYSIS SUCCESSFUL, you can browse to ---

But the dashboard is showing 0.0% code coverage

here is my pom.xml having these important data. I have mentioned the jacoco, surefire plugin. My scoverage.xml report is getting generated having the branch coverage and statement coverage.

<properties>
        <junit.version>4.12</junit.version>
        <scalatest.version>3.0.8</scalatest.version>
        <scala.version>2.11.8</scala.version>
        <scala.major.version>2.11</scala.major.version>
        <maven-scala-plugin.version>2.15.2</maven-scala-plugin.version>
        <scalatest-maven-plugin.version>1.0</scalatest-maven-plugin.version>
        <sonar.scala.scoverage.reportPath>target/scoverage.xml</sonar.scala.scoverage.reportPath>
        <sonar.coverage.jacoco.xmlReportPaths>target/scoverage.xml</sonar.coverage.jacoco.xmlReportPaths>
    </properties>


<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                <!-- Sets the VM argument line used when unit tests are run. -->
                <argLine>${surefireArgLine}</argLine>
                </configuration>
            </plugin>



<plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.8.7</version>
                            <executions>
            
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution> 
                            <execution>
                                <id>report</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>post-unit-test</id>
                                <phase>test</phase>
                                    <goals>
                                        <goal>report</goal>
                                    </goals>
                                    <configuration>
                                        <!-- Sets the path to the file which contains the execution data. -->
                                        <dataFile>target/jacoco.exec</dataFile>
                                        <!-- Sets the output directory for the code coverage report. -->
                                        <outputDirectory>target/jacoco-ut</outputDirectory>
                                    </configuration>
                            </execution>
                        </executions>
                        <configuration>
                <systemPropertyVariables>
                            <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
                </systemPropertyVariables>
                </configuration>
                </plugin>

What is missing? How can I resolve?

Hi,

Welcome to the community!

What does your analysis log say about importing (or not) the JaCoCo report? Have you verified the file actually exists?

 
Ann

If you are talking about jacoco.exec it is not getting generated. Even if I mention in my pom, it was not getting generated.

Hi,

In fact, we no longer import jacoco.exec, but jacoco.xml. You’ll need to get it generated, and unfortunately doing so is out of scope for this community.

 
Ann