Issue Description: Coverage % is empty in SonarQube Pull request analysis page when a PR raised with Single Commit.
Explanation:
When an PR is raised, it will trigger Build Validation Pipeline and Quality Gate Validation for the raised Pull Request in Azure Repos. Code Coverage is generated using Unit Test task and coverage % is generated. Mainly Coverage % for the new code is showing correctly in Build Validation Pipeline, but it’s empty in SonarQube Pull request analysis page (can be accessed via Quality Gate link in PR). This is a occurring for PR’s which contains a single commit.
Coverage % is showing correctly in both places when multiple commits are made in a Pull request.
Checked the logs and can see the coverage files are available and SonarQube is reading it. Issue is with Pull request Quality check. When a PR is raised with Single Commit, SonarQube is not reading Coverage data. You can refer the attached screenshot and this pull request report can be accessed via mentioned URL.
Example: http://sonarqube:8600/dashboard?id=ProjectName&pullRequest=10343
This screenshot doesn’t tell me anything about whether coverage data is being imported or not (and I don’t have access to the link you’ve posted, since it’s running on your local machine)
The logs show coverage information being imported successfully.
2024-02-02T11:12:02.5429881Z INFO: Sensor C# Tests Coverage Report Import [csharp]
2024-02-02T11:12:02.5455147Z WARN: Could not find any coverage report file matching the pattern 'F:\XXXXX\_work\16\TestResults/**/*.coverage'. Troubleshooting guide: https://community.sonarsource.com/t/37151
2024-02-02T11:12:02.5466476Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\07991ef2-ee03-44e5-bb6e-8c04debc0fe4\XXXXXXXX2024-02-02.10_53_53.coveragexml
2024-02-02T11:12:03.1002770Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\07991ef2-ee03-44e5-bb6e-8c04debc0fe4\XXXXXXXX2024-02-02.10_53_53.coveragexml
2024-02-02T11:12:03.1003415Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\1827ba6d-e06f-441a-886a-3b3e20b5875b\XXXXXXXX2024-02-02.10_57_48.coveragexml
2024-02-02T11:12:03.5451926Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\1827ba6d-e06f-441a-886a-3b3e20b5875b\XXXXXXXX2024-02-02.10_57_48.coveragexml
2024-02-02T11:12:03.5458116Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\26f80dd0-5488-4bea-a98f-97bdec3605ff\XXXXXXXX2024-02-02.10_55_59.coveragexml
2024-02-02T11:12:03.9286520Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\26f80dd0-5488-4bea-a98f-97bdec3605ff\XXXXXXXX2024-02-02.10_55_59.coveragexml
2024-02-02T11:12:03.9287492Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\2cbd0068-5f68-48a7-ade5-5796268320ca\XXXXXXXX2024-02-02.10_56_33.coveragexml
2024-02-02T11:12:04.3413734Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\2cbd0068-5f68-48a7-ade5-5796268320ca\XXXXXXXX2024-02-02.10_56_33.coveragexml
2024-02-02T11:12:04.3415228Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\2fca5829-97fc-4078-bcaf-52b5f5236098\XXXXXXXX2024-02-02.10_55_46.coveragexml
2024-02-02T11:12:07.3025432Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\2fca5829-97fc-4078-bcaf-52b5f5236098\XXXXXXXX2024-02-02.10_55_46.coveragexml
2024-02-02T11:12:07.3026118Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\395aedc7-9922-4d9b-b146-1d60b246eee5\XXXXXXXX2024-02-02.10_55_41.coveragexml
2024-02-02T11:12:07.3676700Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\395aedc7-9922-4d9b-b146-1d60b246eee5\XXXXXXXX2024-02-02.10_55_41.coveragexml
2024-02-02T11:12:07.3690197Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\6a64b1e1-d256-44fc-a7c2-2f58ebbe4f6f\XXXX2024-02-02.10_57_06.coveragexml
2024-02-02T11:12:07.7761901Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\6a64b1e1-d256-44fc-a7c2-2f58ebbe4f6f\XXXX2024-02-02.10_57_06.coveragexml
2024-02-02T11:12:07.7765070Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\9ad3498f-73c5-44a5-a0cd-a3c11ad390c8\XXXX2024-02-02.10_58_58.coveragexml
2024-02-02T11:12:10.7046640Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\9ad3498f-73c5-44a5-a0cd-a3c11ad390c8\XXXX2024-02-02.10_58_58.coveragexml
2024-02-02T11:12:10.7047355Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\acc14de7-75f6-46ce-ad18-b970e7b20263\XXXX2024-02-02.10_53_38.coveragexml
2024-02-02T11:12:13.5051281Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\acc14de7-75f6-46ce-ad18-b970e7b20263\XXXX2024-02-02.10_53_38.coveragexml
2024-02-02T11:12:13.5051939Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\f72e6f3f-e166-4205-a434-7468a51b8534\XXXX2024-02-02.10_58_24.coveragexml
2024-02-02T11:12:13.9002216Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\f72e6f3f-e166-4205-a434-7468a51b8534\XXXX2024-02-02.10_58_24.coveragexml
2024-02-02T11:12:13.9005705Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\ff04711c-1f1f-4430-b0b3-ed8ea0e58846\XXXX2024-02-02.10_59_22.coveragexml
2024-02-02T11:12:16.8632255Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\ff04711c-1f1f-4430-b0b3-ed8ea0e58846\XXXX2024-02-02.10_59_22.coveragexml
2024-02-02T11:12:16.8633121Z INFO: Parsing the Visual Studio coverage XML report F:\XXXXX\_work\_temp\ff6e20b8-a115-45d9-a029-3674dfc0e9ca\e82c33d5-f1c6-4dc4-8160-8496b30f8f02.coveragexml
2024-02-02T11:12:26.6427217Z INFO: Adding this code coverage report to the cache for later reuse: F:\XXXXX\_work\_temp\ff6e20b8-a115-45d9-a029-3674dfc0e9ca\e82c33d5-f1c6-4dc4-8160-8496b30f8f02.coveragexml
2024-02-02T11:12:26.8260762Z INFO: Coverage Report Statistics: 390 files, 390 main files, 390 main files with coverage, 0 test files, 0 project excluded files, 0 other language files.
2024-02-02T11:12:26.8263598Z INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=24281ms
So what is showing you that it isn’t? Can you share a screenshot of that?
Yes, I double checked it as well. Even analysed few PR’s which has Single Commit and introduced new code lines where it as covered by test. Can you try to replicate this scenario in your Sandbox environment ?.
There’s really not enough information here to reproduce the issue. So far, it just looks like some of your pull requests don’t have any code that can be covered by tests. By chance, it may be that those PRs only have a single commit.