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
whereas we still see 0% code coverage on sonar server UI. Attaching the screenshot for the reference.
I would request to help us to understand what we are missing.
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:
xxx → 7.9.6 → 8.9.2 → 9.1 (last step optional)
You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.
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.
Hi @ganncamp ,
Thanks for replying back.
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 126.96.36.199852. 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.
Sonar scanner info
Project scanner properties:
Scanner properties of module: CoverageJaCoCoUnit:analytics-ui
We have several dozen modules and the coverage of the .xml file is created by merging the jacoco.exec file from the individual modules.
Our plugin info
- Python Code Quality and Security 188.8.131.5266 (python)
- CSS Code Quality and Security 184.108.40.2062 (cssfamily)
- Go Code Quality and Security 220.127.116.119 (go)
- JaCoCo 18.104.22.1687 (jacoco)
- Kotlin Code Quality and Security 22.214.171.1249 (kotlin)
- Ruby Code Quality and Security 126.96.36.1999 (ruby)
- Scala Code Quality and Security 188.8.131.529 (sonarscala)
- C# Code Quality and Security 184.108.40.206243 (csharp)
- Groovy 1.8 (groovy)
- Java Code Quality and Security 220.127.116.11025 (java)
- HTML Code Quality and Security 18.104.22.16854 (web)
- Flex Code Quality and Security 22.214.171.12464 (flex)
- XML Code Quality and Security 126.96.36.19973 (xml)
- PHP Code Quality and Security 188.8.131.5239 (php)
VB.NET Code Quality and Security 184.108.40.206243 (vbnet)
Please can you advise me what’s going on? Would an update help?
Hi @ganncamp and @puci ,
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.
- 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.
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:
- Please ensure that jacoco related configuration is correct:
- 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:
Reference: Test Coverage & Execution | SonarQube Docs
@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 …
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.