We have recently upgraded our sonar application from 7.1 to 7.9.6 (LTS in 7.x).
We have observed that code coverage is showing 0% for java projects using maven as build tool and jacoco as code coverage.
Please note that we are getting non zero code coverage for sonar 7.1 (Before upgrade) for same java projects.
We have observed that jacoco plugin property sonar.jacoco.reportPaths which was being used in Sonar 7.1 is no longer supported in Sonar 7.9.6.
Instead, we are using updated property sonar.coverage.jacoco.xmlReportPaths in pom.xml file.
We are using below code snippet for code coverage in our pom.xml file:
Please note that we have removed some lines from pom.xml which contains organization specific information.
Jacoco version installed: 1.1.0 (build 898)
Java Code Quality and Security: 6.3.2 (build 22818)
One observation: We are able to see non zero code coverage in target/site/jacoco/index.html file
whereas we still see 0% code coverage on sonar server UI. Attaching the screenshot for the reference.
Congratulations on your upgrade to 7.9.6. And you need to keep going. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:
Regarding your actual question, it’s not worth trying to debug this in an EOL version. Once you’ve consulted the LTS-to-LTS Upgrade Notes, you’ll see that the accepted report format for JaCoCo has changed & you’ll need to catch that up. And if there’s still a problem at that point, then please come back to us.
We are actually upgrading from 7.1 to 8.9.2. We had to upgrade to 7.9.6 because that’s supported path for upgrade.
In order to stabilise our environment @7.9.6, we need to fix this issue.
Hence we need a help.
Yes, I understand. But this is just a waypoint. There’s no point in spending time to stabilize this when you know you’re just going to move right past it. Go ahead & do the upgrade to 8.9.1 and then we can work on this.
Hi @ganncamp ,
I have the same problem and I have SonarQube version 8.9.0.43852. Please, is it possible that the coverage is not working due to the wrong version?
Some debug info
Sensor JaCoCo XML Report Importer [jacoco]
Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
I am pleased to inform you that our issue is resolved.
I would like to share the fix so that anyone facing the same issue may get the help.
Possible Causes:
Unit test cases are missing.
sonar-maven-plugin is not defined in pom.xml file.
Language and tool-specific maven plugin (for an example, Jacoco) is not defined in pom.xml
Jacoco plugin related configuration in pom.xml is not correct.
Solutions:
SonarQube doesn’t run your tests or generate reports. It only imports pre-generated reports. We have to use language and tool-specific analysis parameters for importing coverage and execution reports. Please ensure that you have at least one unit test case defined for your project.
Please ensure that sonar-maven-plugin is defined in pom.xml:
If your jacoco reports are generated at custom path (other than default path: target/site/jacoco/jacoco.xml ) OR if you are using deprecated sonar property( sonar.jacoco.reportPaths ) for jacoco then please update sonar property as below: <sonar.coverage.jacoco.xmlReportPaths>your/custom/path/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
@jariwala I’m afraid the issue will definitely not solve me (as I wrote in the post, I have the right paths and current properties) and I use gradle with correct sonar plugin, but thank you for trying help me …