Sdk: Code Coverage does not work even after adding the code coverage nuget.

Created on 22 Mar 2016  路  7Comments  路  Source: dotnet/sdk

Steps to reproduce

The attached project has a simple xunit test. There are two ways to repro this:

The more easier way of reproing this is : From a developer command prompt run vstest.console.exe project.json /useVsixExtensions:true /enableCodeCoverage

For the VS IDE repro you can use this:

  1. Open it in VS.
  2. Open Test Explorer.(Test -> Windows -> Test Explorer)
  3. Build the solution to trigger discovery.
  4. Right Click on the discovered test and "Analyze code coverage"

Repro.zip

Expected behavior

A code coverage file that covers the project under test with no errors.

Actual behavior

The following error occurs:
Error: Unable to start C:\Program Files\dotnet\bin\dotnet.exe

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.CodeCoverage.Shim, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.DotNet.Cli.Program.Main(String[] args)

This scenario works if I manually drop the CodeCoverage.Shim dll that the nuget package contains under %ProgramFiles%/dotnet/bin.

Environment data

dotnet --version output:

release blocking

Most helpful comment

Why is this issue closed if the problem is not solved?

All 7 comments

This scenario works if I manually drop the CodeCoverage.Shim dll that the nuget package contains under %ProgramFiles%/dotnet/bin.

Even with this workaround code coverage seems to be working only for netstandard assemblies, but not for net4褏褏 ones. In other words, in the VS's Code Coverage Results only netstandard assemblies are listed, though I know that net4xx assemblies were called by the tests.

@dotnet/vstest I'm going to close this issue on CLI, but getting Code Coverage as a feature in the near future will be great :D

Why is this issue closed if the problem is not solved?

Same for VS 2017...

System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.VisualStudio.CodeCoverage.Shim, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

no work.......

I have the same issue as of today. .NET Core 2.0 project XUNIT test project.

same for me on my xUnit project on the .NET Standard style *.csproj files. .NET Framework old style *.csproj files like the ones here: https://github.com/Elskom/zlib.managed/ are not affected.
I am tempted to add a command to dotnet test that generates a coverage xml file like I use OpenCover for so that way I can drop OpenCover and use dotnet test for the coverage file to codecov.io.

Was this page helpful?
0 / 5 - 0 ratings