coverlet-coverage / coverlet

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

0 coverage when running integration tests in ASP.NET Core #SonarQube #1128

Open sw-ms-ankitsangani opened 3 years ago

sw-ms-ankitsangani commented 3 years ago

Hello @All,

Please Help... We have a solution with some Integration tests, but no unit tests. And I was stuck cant generate code coverage. here is my command Line.

dotnet restore ""

dotnet sonarscanner begin /k:"" /d:sonar.host.url="" /d:sonar.login=""

dotnet build "" -c Release -o /app/build

dotnet test "" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover

dotnet sonarscanner end /d:sonar.login=

NOTE : We have get coverage % on unit test using this command line but not integration test.

Thanks In Advanced...

nikita030493 commented 3 years ago

Same issue. coverage is missing for 3.0.0 <
Rolling back to 2.9.0 solved the issue.

tai-yi commented 3 years ago

Resolved with command dotnet test --collect:"XPlat Code Coverage" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover , only add --collect:"XPlat Code Coverage", I'm using .net5

MarcoRossignoli commented 3 years ago

If you've integration it's possible that you're suffering of known problem(related to slow tests shutdown)

https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#vstest-stops-process-execution-early

You should try with collectors integration https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md

@tai-yi you need to remove "/p:CollectCoverage=true /p:CoverletOutputFormat=opencover" and pass argument with runsettings, take a look at documentation above