I have a bit of a problem getting code coverage reports for both Integration Tests and Unit Tests in Sonar for a Maven Plugin project (which uses invoker plugin for the integrat
Since you've configure the sonar as
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.itReportPath>
${project.basedir}/target/jacoco-t.exec
</sonar.jacoco.itReportPath>
This means you are telling sonar to reuse the existing report from sonar.jacoco.itReportPath. If there is no existing report, there is no any coverage.
In may case, I use the cobertura and reuse its report from maven site generation. as the following configuration properties: -
<sonar.java.coveragePlugin>cobertura</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.surefire.reportsPath>
${project.build.directory}/surefire-reports
</sonar.surefire.reportsPath>
<sonar.cobertura.reportPath>
${project.build.directory}/site/cobertura/coverage.xml
</sonar.cobertura.reportPath>
I can get the reuse by using the following command :-
mvn clean install site sonar:sonar
I can reproduce your issue by using the following command :-
mvn clean install sonar:sonar
The coverage is 0%. Since there is no existing report at the report path.
Then please make sure that there is a report named "jacoco-t.exec" as specified before executing the sonar.
Since I'm not familiar with the JaCoCo and do not know which maven phase that produces thae report file. I would suggest to execute the command like the following:-
mvn clean test sonar:sonar
or
mvn clean install sonar:sonar
or the same as mine
mvn clean install site sonar:sonar
I hope this may help.
Regards,
Charlee Ch.