I can see both test results trx files that have been generated by the pipeline in the logs as well as the two coveragexml files. But the result is always 0% code coverage. I have also checked that the newly written tests go through the new code and they do.
Not sure why it is reporting 0% coverage, but it has started happening on one project only within the last week. No changes to build process, but change was made to use Microsoft.TestPlatform&version=17.11.1 in the cake file that runs and produces the test files.
Thanks in advance for any help that can be given. Log.txt (2.5 MB)
2024-10-31T17:07:22.0069010Z INFO: Sensor C# Tests Coverage Report Import [csharp]
2024-10-31T17:07:22.0083401Z INFO: Parsing the Visual Studio coverage XML report C:\a\2\s\TestResults\AzDevOps_eu1vs22000VRR_2024-10-31_16_53_17\In\eu1vs22000VRR\AzDevOps_eu1vs22000VRR_2024-10-31.16_54_02.coveragexml
2024-10-31T17:07:22.0364574Z INFO: Adding this code coverage report to the cache for later reuse: C:\a\2\s\TestResults\AzDevOps_eu1vs22000VRR_2024-10-31_16_53_17\In\eu1vs22000VRR\AzDevOps_eu1vs22000VRR_2024-10-31.16_54_02.coveragexml
2024-10-31T17:07:22.0366020Z INFO: Parsing the Visual Studio coverage XML report C:\a\2\s\TestResults\AzDevOps_eu1vs22000VRR_2024-10-31_16_59_31\In\eu1vs22000VRR\AzDevOps_eu1vs22000VRR_2024-10-31.17_03_44.coveragexml
2024-10-31T17:07:22.0367723Z INFO: Adding this code coverage report to the cache for later reuse: C:\a\2\s\TestResults\AzDevOps_eu1vs22000VRR_2024-10-31_16_59_31\In\eu1vs22000VRR\AzDevOps_eu1vs22000VRR_2024-10-31.17_03_44.coveragexml
2024-10-31T17:07:22.0369163Z INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=16ms
2024-10-31T17:07:22.0369800Z INFO: Sensor C# Unit Test Results Import [csharp]
2024-10-31T17:07:22.0373459Z INFO: Parsing the Visual Studio Test Results file 'C:\a\2\s\TestResults\AzDevOps_eu1vs22000VRR_2024-10-31_16_53_17.trx'.
2024-10-31T17:07:22.0728729Z INFO: Parsing the Visual Studio Test Results file 'C:\a\2\s\TestResults\AzDevOps_eu1vs22000VRR_2024-10-31_16_59_31.trx'.
2024-10-31T17:07:22.0813069Z INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=46ms
My first two suggestions are:
Examine this file (C:\a\2\s\TestResults\AzDevOps_eu1vs22000VRR_2024-10-31_16_59_31\In\eu1vs22000VRR\AzDevOps_eu1vs22000VRR_2024-10-31.17_03_44.coveragexml) to see if it actually contains coverage data. SonarQube doesn’t do anything special with coverage data other than read the file it’s given. If this file contains no coverage data… SonarQube won’t be able to detect it. At that point, you know the issue is with your coverage tool and the priority and getting the report back in shape.
Turn on DEBUG logging (sonar.verbose=true), which offers more detailed logging on the coverage import.
If you have any scanner logs from before the coverage dropped to 0, that’s also helpful to compare if something else changed.