Code coverage keeps showing 0.0%


I’ve spend quite some time trying to get code coverage to work without success so far. If there’s anyone who can provide any assistance it would be greatly appreciated!


  • ALM: Azure DevOps;

  • CI: Azure Devops;

  • Framework: .NET 4.7

  • Scanner properties:


Visual Studio Test Task

Test results folder: $(Agent.TempDirectory)/TestResults

Note that this matches the sonar.cs.vstest.reportsPaths property.

Log summary


Results File: D:\AzureNL_2\_work\_temp\TestResults\xxxxxxxxxxxxxxxxxxxxxxxx_2020-12-17_09_16_49.trx


  D:\AzureNL_2\_work\_temp\TestResults\07875087-cb6c-4056-8bd7-55a7e3445868\xxxxxxxxxxxxxxxxxxxxxxxx 2020-12-17 09_16_41.coverage

  D:\AzureNL_2\_work\_temp\TestResults\966f46de-094c-424c-86d0-305bd85473a1\xxxxxxxxxxxxxxxxxxxxxxxx 2020-12-17 09_16_41.coverage

  D:\AzureNL_2\_work\_temp\TestResults\8c9ace28-ec73-4f35-b11b-c4d203a6d9a2\xxxxxxxxxxxxxxxxxxxxxxxx 2020-12-17 09_16_41.coverage

  D:\AzureNL_2\_work\_temp\TestResults\730b3348-7108-4370-97c5-d8f5cdb6421d\xxxxxxxxxxxxxxxxxxxxxxxx 2020-12-17 09_16_41.coverage

  D:\AzureNL_2\_work\_temp\TestResults\0d0ab4a9-f9e9-4253-a5c7-70fd733b5ff0\xxxxxxxxxxxxxxxxxxxxxxxx 2020-12-17 09_16_50.coverage

  D:\AzureNL_2\_work\_temp\TestResults\13af933a-8118-4550-8734-021913eb31b7\xxxxxxxxxxxxxxxxxxxxxxxx 2020-12-17 09_16_51.coverage

  D:\AzureNL_2\_work\_temp\TestResults\a77ad44c-6e5e-4db8-8938-d17f57389c4d\xxxxxxxxxxxxxxxxxxxxxxxx 2020-12-17 09_16_52.coverage

Total tests: 179. Passed: 178. Failed: 0. Skipped: 1.

Test Run Successful.

Test execution time: 13,0764 Seconds

Vstest.console.exe exited with code 0.

**************** Completed test execution *********************

Test results files: D:\AzureNL_2\_work\_temp\TestResults\xxxxxxxxxxxxxxxxxxxxxxxx_2020-12-17_09_16_49.trx


Run Code Analysis Task





Property 'sonar.cs.vstest.reportsPaths' provided, skipping the search for TRX files in default folders...

Did not find any binary coverage files in the expected location.

Falling back on locating coverage files in the agent temp directory.

Searching for coverage files in D:\AzureNL_2\_work\_temp


09:17:43.556 INFO: Sensor C# Unit Test Results Import [csharp]

09:17:43.556 DEBUG: Pattern matcher extracted prefix/absolute path 'D:\AzureNL_2\_work' from the given pattern 'D:\AzureNL_2\_work\_temp/TestResults/*.trx'.

09:17:43.556 DEBUG: Gathering files for wildcardPattern '_temp/TestResults/*.trx'.

09:17:59.759 DEBUG: Pattern matcher returns '1' files.

09:17:59.759 DEBUG: The current user dir is 'D:\AzureNL_2\_work\12'.

09:17:59.759 INFO: Parsing the Visual Studio Test Results file 'D:\AzureNL_2\_work\_temp\TestResults\xxxxxxxxxxxxxxxxxxxxxxxxx_2020-12-17_09_16_49.trx'.

09:17:59.775 DEBUG: Parsed Visual Studio Test Times - duration: 14438.

09:17:59.775 DEBUG: Parsed Visual Studio Test Counters - total: 179, failed: 0, errors: 0, timeout: 0, aborted: 0, executed: 178.

09:17:59.775 INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=16219ms


When not specifiying sonar.cs.vstest.reportsPaths the output is as follows:

Attempting to locate a test results (.trx) file...

Looking for TRX files in: D:\AzureNL_2\_work\12\TestResults

No test results files found

Did not find any binary coverage files in the expected location.

Falling back on locating coverage files in the agent temp directory.

Searching for coverage files in D:\AzureNL_2\_work\_temp


  • The Run Code Analysis Task log shows that it can’t find the .trx but then it can!?

  • The dashboard does show the number of tests however the coverage is still 0.0%.

  • Clicking the number of test shows the text ‘No results’.

  • When not using the sonar.cs.vstest.reportsPaths the scanner looks is ‘TestResults’ and not $(Agent.TempDirectory)/TestResults (which is the default).

What do I need to do to get the dashboard to show a coverage percentage other then 0.0%? How to display the actual results of the unit tests?

Hello, @estavenuiter,

Please refer to

The property sonar.cs.vstest.reportsPaths that you try to set are to report tests results (x tests runs, y failed, z skipped, % successful), not the test coverage.
Whether these properties are well set or not, they will not report coverage, only somes stats in the Test measures (see Project Home page --> Measures Tab --> Tests on the left pane)

To get coverage reported you must set one of sonar.cs.vscoveragexml.reportsPaths, sonar.cs.dotcover.reportsPaths or sonar.cs.opencover.reportsPaths depending on the coverage tool you use (and obviously pointing at a correct coverage report file corresponding to the tool).