Must-share information (formatted with Markdown):
- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
SonarQube * Developer Edition Version 8.0 (build 29455)
- what are you trying to achieve
Attempting to get accurate code coverage in SonarQube UI
- what have you tried so far to achieve this
I’ve tried multiple times to run all tests with coverage in IntelliJ and then run sonar.
Despite multiple attempts to get SonarQube to display accurate code coverage I continue to get inaccurate results in the UI. It has actually started showing less coverage than it did in the beginning despite the fact that I have added _more_coverage. The first of the below images shows the line numbers and code coverage for a method within IntelliJ, as you can see it shows the entire method is covered (there had been some gaps before). The second image shows the same method’s code coverage as reported by the SonarQube UI, as you can see it shows the entire method as not being covered. This particular file had started out with 9 new lines, 5 of which had no coverage. After I removed two unneeded lines taking the new lines down to seven and adding tests to cover the other lines it started showing that there were seven uncovered lines. The lines I removed had not been covered by tests to start with so even without the new tests it should have shown 7 new lines with 3 uncovered.
There are also at least four other files where I have added tests to cover all of the new lines and yet the UI still shows none of those lines as being covered.
Is there some trick I need to use to get SonarQube to update the coverage for specific files, or all the files?
I have been running all tests in the project through IntelliJ with coverage and then immediately running
jacoco:prepare-agent jacoco:report sonar:sonar -Dsonar.login=…. I’ve lost count of how many times I’ve tried this after adding various tests to boost coverage in the project.