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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With