Code Coverage for Integration tests didn't show in sonarqube

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    I am using sonarqube 8.4.2
  • what are you trying to achieve
    I am generating jacoco.exec using jacoco agent for integration tests in a separate repository. After generating jacoco.exec and xml report trying to publish to sonar qube. But report is not publishing to sonar qube with the configuration I have added in pom.xml
  • what have you tried so far to achieve this

In Integration tests repo pom.xml I made following changes. But when I tried mvn sonar: sonar. code coverage which is available in jacoco.exec and jacoco.xml not publishing to sonarqube

<properties>
    <!-- Sonar -->
    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.coverage.jacoco.reportPath>/path/functional-tests/target/jacoco-ft.exec</sonar.coverage.jacoco.reportPath>
    <sonar.coverage.jacoco.xmlReportPaths>path/functional-tests/target/my-report/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
    <sonar.coverage.jacoco.sourceDirectory>/path/src/main/java</sonar.coverage.jacoco.sourceDirectory>
    <sonar.language>java</sonar.language>
</properties>
<plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.3</version>

                <configuration>
                    <address>127.0.0.1</address>
                    <destFile>${sonar.coverage.reportPath}</destFile>
                    <port>6300</port>
                    <reset>false</reset>
                    <append>true</append>
                </configuration>

                <executions>
                    <execution>
                        <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>

                <execution>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>dump</goal>
                    </goals>
                </execution>

                <execution>
                    <id>jacoco-report</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <configuration>
                      <dataFile>/path/functional-tests/target/jacoco-ft.exec</dataFile>
                        <outputDirectory>/path/functional-tests/target/my-report</outputDirectory>
                    </configuration>
                </execution
                </executions>
            </plugin>

Hi,

By 8.4 the .exec format is no longer supported. You’ll need to make sure you provide XML reports for all your data. I believe JaCoCo provides a step to merge reports, but that’s outside my area of expertise.

 
HTH,
Ann

Thanks Ann for responding back. I have given xml report in the path like below and tried. In xml all the data is available. Still data is not publishing

<sonar.coverage.jacoco.xmlReportPaths>path/functional-tests/target/my-report/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>

Hi,

I find this path a little odd. Isn’t target usually in the project/module root directory?

 
Ann