coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.98k stars 385 forks source link

Coverage locally though CLI returns 0% when ran though Visual Studio Test -> Analyze Code Coverage for All Tests getting correct data #1362

Closed vishnuprakash9845 closed 2 years ago

vishnuprakash9845 commented 2 years ago

I'm currently facing a different problem, which may be related to using the latest .NET Core 6.0 . (I don't know for sure).

On my computers coverage works fine with Visual Studio IDE , but when running on a CLI getting coverage as 0%. Not sure what's going wrong.

Through IDE: image

In the CLI:

Below command is used to run coverlet .\bin\debug\net6.0\XunitTestFramework.dll --target "dotnet" --targetargs "test --no-build"

image

Following packages I used in my project:

image

I'm completely blank why this kind on different behavior, can anyone help me to solve this issue.

Thanks for your time!

andrei-epure-sonarsource commented 2 years ago

Hi @vishnuprakash9845

Did you read the Known issues? https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#known-issues

One of the mentioned symptom is:

zero coverage result (often only on CI but not on local)

Also the Readme seems to mention xunit in https://github.com/coverlet-coverage/coverlet#vstest-integration-preferred-due-to-known-issue

vishnuprakash9845 commented 2 years ago

@andrei-epure-sonarsource

Thanks for the response.

I missed to see that known issue. But bit surprised to see the issue still open for some time.

For time being I got the workaround for the issue from the link you shared.

image

Its working fine.

image