Template for a good new topic, formatted with Markdown:
ALM used: GitHub
CI system used: Travis CI
Languages of the repository : PHP
Steps to reproduce;
We have setup a project using PHPUnit attempting to show code coverage in Sonarcloud. We have several projects in Sonarcloud all setup the same way, however only one has this issue;
We run PHPUnit to generate a coverage.xml and a results.xml - checking the contents of the file we can see the lines of code we expect to be covered are, however when looking at Sonarcloud it does not show the lines as covered. Using identical config but passing the results in to a dockerised Sonarqube instance does show the lines as covered as expected. This uses the same sonar-project.properties file.
Potential workaround;
No workaround found as of yet.
The only log entry relating to code coverage is INFO: Importing /home/travis/build/{REDACTED}/{REDACTED}/codebase/tests/coverage.xml and other coverage is showing OK. We use Travis to run our CI Pipeline so are using the sonar-scanner command available when using the sonarcloud addon in our TravisCI
The codebase is a Drupal9 codebase so we have the following in our properties file;
Hey,
I can, yes - I have debugged the build on Travis and can confirm the file is generated and that when searching through the file manually, I can find the lines I expect to be covered showing as having coverage.
I’m not seeing any errors in the logs relating to it picking up the coverage file and we see INFO: Importing /home/travis/build/redacted/redacted/codebase/tests/coverage.xml so it all looks to be picking up correctly as expected, we’re just not seeing the coverage picked up by Sonarcloud but is when using a Sonarqube docker instance.
I would try it, and please let me know the results. ( if it is not working by default, I would also try to remove sonar.php.tests.reportPaths=codebase/tests/results.xml and just leave the values for sonar.php.tests.reportPath).
Thank you Nils and Csaba for your assistance on this! A combination of incorrect key names, incorrectly setup code coverage filters. Appreciate the extra logging and comments on this thread.