SQ/Azure Dev Ops - CSharp - Code Coverage does not get picked up

Issue: Code Coverage does not get picked up even though the number of unit tests being run does get picked up.

Versions Used:

  • SonarQube Server:
  • DevOps Agent Image: windows-latest
  • VSTest: 2.170.1
  • SonarScanner for MSBuild 4.10

After 2 weeks of investigation, I have confirmed that the tests are being run, the trx file is being generated and it does have the information regarding the number of tests being run. It also has a link to a .coverage file but I have not been able to verify the data in the .coverage file. All I can say is it’s got some data because it is about 2MB. I looked through the logs for the Run Analysis task and the Publish results task and confirmed that it’s picking up the data from the TRX file:

16:55:00.381 DEBUG: Parsed Visual Studio Test Times - duration: 359511.
16:55:00.429 DEBUG: Parsed Visual Studio Test Counters - total: 637, failed: 0, errors: 0, timeout: 0, aborted: 0, executed: 636.
16:55:00.437 INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=1418ms

And yet, Code Coverage for the project still shows up as 0% in SQ. Any suggestions or thoughts?

Hi @harivrdhn_vwac and welcome to our community.

Did you read the Code Coverage is not shown in the SonarCloud.io topic? Could you follow the advice given there to diagnose your problem?

You can also read this answer for more info and tips Scanner for MSBuild URL https://docs.sonarqube.org/x/CoB is broken