We are using a hosted version of SonarQube, and have configured it to ingest our phpunit coverage several xml files.
We have encountered an odd situation where xdebug/phpunit is showing 100% coverage for a single file locally, but Sonar is reporting approximately 56%.
We are using clover as the XML format.
One thing that may play into this, is that we have to runs of the same test suite, each generating their own coverage files.
I’ve only been able to find dead links to a blog post about “executable lines”, so I’m at my wits end with this.
edit: After some further digging, sonar is complaining about lines of code not being tested, but the tests would not actually pass if that were the case.
However looking at the clover results. We’re importing one xml where SomeFile.php is 100% covered in one run of the unit tests.
The next time we run the suite, we don’t run any tests for SomeFile.php and the clover xml shows 0% coverage for that file.
I’ll mention that we’re using Enterprise 9.9.5 and have configured the coverage clover paths from the web ui, and are not passing them using sonar-scanner
I ran a little test this morning where I sent two coverage files to SonarQube, one marking the line as covered and one not. I ended up with 100% coverage. Just to be extra sure, I even flipped around the order of the reports being passed into sonar.php.coverage.reportPath.
In the logs, I see both coverage files parsing correctly. It would be good if you confirmed that as well.
I would reckon that any further troubleshooting would require you to provide a sample project this can be reproduced on, since we can’t reproduce it on our side.