coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.97k stars 386 forks source link

Could not find data collector 'XPlat Code Coverage' when targetting .dll #1118

Closed captainjono closed 3 years ago

captainjono commented 3 years ago

> dotnet add package coverlet.collector dotnet test my.csproj --collect:\"XPlat Code Coverage\" works. great!

dotnet test bin/debug/netcoreapp3.1/test.dll --collect:\"XPlat Code Coverage\"

Data collection : Unable to find a datacollector with friendly name 'XPlat Code Coverage'.
Data collection : Could not find data collector 'XPlat Code Coverage'

What am i missing here? Im writing a tool that integrates with coverage so i would like to support both scenarios.

dotnet --version = 5.0.101

MarcoRossignoli commented 3 years ago

Can you try with

dotnet vstest bin/debug/netcoreapp3.1/test.dll --collect:\"XPlat Code Coverage\"

As explained in guide for published project https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md

captainjono commented 3 years ago

Can you explain why I cant use dotnet test ?

None of the examples here use vstest ?

Like i said, Im writing a tool that is supposed to let users execute any test written by any test framework. My understanding was dotnet test facilitated this.

https://github.com/dotnet/docs/issues/14786#issuecomment-642280142

On Tue, Mar 16, 2021 at 7:26 PM Marco Rossignoli @.***> wrote:

Can you try with

dotnet vstest bin/debug/netcoreapp3.1/test.dll --collect:\"XPlat Code Coverage\"

As explained in guide for published project https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/coverlet-coverage/coverlet/issues/1118#issuecomment-800058857, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOPWTVV7ERJJICP76OXUUDTD4I2TANCNFSM4YZNACLA .

MarcoRossignoli commented 3 years ago

It's an implementation detail of test platform, we don't load collectors we implement one, you should open an issue and ask here https://github.com/microsoft/vstest/issues

RussKie commented 1 year ago

The solution is described here: https://github.com/coverlet-coverage/coverlet/issues/521#issuecomment-824135206