Problems setting up code coverage with sonarsource

Template for a good new topic, formatted with Markdown:

  • ALM used GitHub
  • CI system GitHub Actions*
  • Scanner command used when applicable (private details masked) I used the gradle plugin
  • Languages of the repository Kotlin
  • Only if the SonarCloud project is public, the URL https://sonarcloud.io/project/overview?id=reisi007_reisishot.pictures
    • And if you need help with pull request decoration, then the URL to the PR too —
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting): **No coverage information (see more info below)
  • Steps to reproduce run the CI / the CI commands manually
  • Potential workaround –

So… My problem is the following: I have 0.0% code coverage… I mean, my code coverage is low (<5%) but definitely not 0%.

I use an aggregated report and the generated HTML report states the code coverage as follows:

So I kind of expect my code coverage to be either 2% or 4%

The next question is: Is Sonar using the generated XML?

2022-01-29T09:32:20.432+0100 [INFO] [org.sonarqube.gradle.SonarQubeTask] Sensor JaCoCo XML Report Importer [jacoco]
2022-01-29T09:32:20.433+0100 [INFO] [org.sonarqube.gradle.SonarQubeTask] Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
2022-01-29T09:32:20.433+0100 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Reading report 'S:\Reisishot\MiSe\build\reports\jacoco\jacocoAggregatedReport\jacocoAggregatedReport.xml'
2022-01-29T09:32:20.526+0100 [INFO] [org.sonarqube.gradle.SonarQubeTask] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=96ms

Which is the XML version of the HTML report listed above. This seems to happen for every subproject. However, I do not care as I have a three step approach

  1. Run tests (and generate reports)
  2. Combine reports
  3. Run sonar

So in any case the combined report should not change at all during the sonar run…

How do I get the code coverage to be reported correctly…?

1 Like

Hey @reisi007

It looks like coverage is now being reported on your project – were you able to resolve the issue?

1 Like

After integrating codecov (which worked on first try) in addition to Sonarcloud it started to work somehow / at some later time…

So it is resolved, but I didn’t change anything (expect by chance).

I guess this is bad, the only tip I can give: if you think it should work, don’t try to fix it for a week or so…

1 Like