question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Coverage Report not Generated When Running through VS 2019 Test Explorer -- coverlet.collector

See original GitHub issue

This issue is occurring when using coverlet.collector v1.0.0. Essentially coverage reports are generated when I run tests through the command line, but when running through the Test Explorer, coverage reports are not generated.

I have set up a .runsettings file which essentially just describes which format to use and some custom exclusions I need for my project:

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat code coverage">
        <Configuration>
          <Format>lcov</Format>
          <Exclude>[*.tests]*,[*.testing]*,[xunit.*]*,[*.SqlServer]*</Exclude> <!-- [Assembly-Filter]Type-Filter -->
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

I have selected this .runsettings file to be used in VS2019 through the Test > Test Settings > Select Test Settings File option. When I run a test using the Test Explorer, it generates the folder, but never actually spits out the coverage report.

Additional Details: I have a tests project called Refactored.Web.Tests. When I run through the console: dotnet test dotnet/Tests/Presentation/Refactored.Web.Tests/Refactored.Web.Tests.csproj --no-restore --settings coverletArgs.runsettings it generates a folder in dotnet/Tests/Presentation/Refactored.Web.Tests/TestResults with the coverage report in said folder.

When I run it through the Test Explorer, it generates a folder in the root of the solution at dotnet/TestResults but without the associated coverage report.

Is there something I’m missing to get this to generate as expected?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
vagisha-nidhicommented, Jul 9, 2019

@MarcoRossignoli @Stefanie899 Yes the issue is related to VS integration. Any custom datacollector path is not automatically known when running via VS. In dotnet test, this happens because we set the test adapter path to find the datacollector in the targets file https://github.com/tonerdo/coverlet/blob/master/src/coverlet.collector/build/netstandard1.0/coverlet.collector.targets

As a workaround, you can specify the test adapter path to the coverlet.collector nuget path as below.

<RunSettings>
  <RunConfiguration>
    <TestAdaptersPaths>C:\Users\vanidhi\.nuget\packages\coverlet.collector\1.0.1\build\netstandard1.0\</TestAdaptersPaths>
  </RunConfiguration>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat code coverage">
        <Configuration>
          <Format>lcov</Format>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

Meanwhile, I will log this issue on vstest to get this addressed.

0reactions
tonyhallettcommented, Jun 8, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Coverage Report not Generated When Running through ...
This issue is occurring when using coverlet.collector v1.0.0 . Essentially coverage reports are generated when I run tests through the command ...
Read more >
Troubleshoot code coverage - Visual Studio
If none of the tests are executed, there's nothing for code coverage to report. Resolution. In Test Explorer, select Run All to verify...
Read more >
Coverlet does not generate single coverage report file for ...
We are trying to generate and report Code Coverage to azure server using Coverlet and ReportGenerator. We are collecting coverage report in ......
Read more >
Why dotnet test tool is not creating code coverage report?
Basically I forgot to add the coverlet msbuild NuGet package into my test project. After that, all worked fine with the following command:...
Read more >
How to view code coverage with Coverlet and Visual ...
The first thing to do to add code coverage reports to our project is to install Coverlet, a NuGet package, whose documentation can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found