Code Coverage shows 0% for Java (JDK 17, Maven, Gitlab CI) project

Hi team,

I am trying to do a sonarqube analysis, show it on the dashboard and show the code coverage of our Java 17 project.
The sonarqube dashboard successfully shows the Project (including code smells, bugs, etc.), but code coverage is showing 0% and though test source code is visible, lines of Code are shown as null.
We run on SonarQube version 10.2.1

We are using a - mvn package sonar:sonar -Pcoverage
(integration tests run on dockerized system, therefor no verify), the POM.xml contains jacoco plugin as described here: Java test coverage
Following is shown in my Stack trace:
[INFO] Sensor JavaSensor [java] (done) | time=5969ms
[INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] ‘sonar.coverage.jacoco.xmlReportPaths’ is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
[INFO] No report imported, no coverage information will be imported by JaCoCo XML Report Importer
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms

Could you please support ?

Found the answer. jacoco report is binding by default to maven verify. You need to bind that to the phase package in my case.

1 Like