Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aggregated Coverage or Coverage in the dependent modules not shown in SonarQube + Reports are generated by Jacoco

I am running jacoco plugin to generate html , xml and jacoco.exec reports to measure the coverage of the code tested by my testNg tests.

I am successful in the generation of these reports in my local as well as in Jenkins and all my unit test results are reflected in Sonar and it's showing me the coverage.

My jacoco.exec has both results of the coverage in the module and the dependent modules. I have verified this using eclemma plugin for eclipse.

I am not getting the coverage results in the dependent modules in Sonar.Does any one what I am doing wrong.

My plugin goes like this

<plugin>
 <groupId>org.jacoco</groupId>
 <artifactId>jacoco-maven-plugin</artifactId>
 <version>0.7.7.201606060606</version>
 <executions>
    <execution>
        <goals>
            <goal>prepare-agent</goal>
        </goals>
    </execution>
    <execution>
        <id>report</id>
        <phase>prepare-package</phase>
        <goals>
            <goal>report</goal>
        </goals>
    </execution>
  </executions>
</plugin>

and my goal is jacoco:report-aggregate

like image 992
JITHIN_PATHROSE Avatar asked Oct 06 '18 07:10

JITHIN_PATHROSE


1 Answers

I got the answer from jacoco plugin coverage in multi-module

The following were the mistakes that I did which caused problem form me. In the properties of our pom

 <sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>

and in plugin

 <destFile>${sonar.jacoco.reportPath}</destFile>

for me, the above statement flushed the jacoco.exec in different folders because of difference in maven module hierarchy as a result they never agrregated.

The second point is that the dependent module coverage will be only obtained only if it is a compile time dependency to the testing module.

like image 90
JITHIN_PATHROSE Avatar answered Oct 01 '22 06:10

JITHIN_PATHROSE