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

Created on 8 Jul 2019  路  3Comments  路  Source: coverlet-coverage/coverlet

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?

question

Most helpful comment

@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.

All 3 comments

Essentially coverage reports are generated when I run tests through the command line, but when running through the Test Explorer

@vagisha-nidhi any ideas?
Seem related to VS integration

@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.

Thanks Vagisha for investigation, can you link here issue from vstest repo for @Stefanie899?
I'm going to close this because unrelated to Coverlet.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexanderkozlenko picture alexanderkozlenko  路  8Comments

arpit-nagar picture arpit-nagar  路  4Comments

arohithr8 picture arohithr8  路  5Comments

obtuse-whoosh picture obtuse-whoosh  路  6Comments

ghost picture ghost  路  5Comments