coverlet-coverage / coverlet

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

coverage not reported when some tests fail #1509

Closed nreddipalle closed 1 day ago

nreddipalle commented 1 year ago

I am using following command

dotnet test "$(Build.SourcesDirectory)/Tests/ResourcePlanning.Tests/ResourcePlanning.Tests.csproj" --logger "trx;logfilename=resourceplanningtests-testResults$count.trx" --results-directory "$(Agent.TempDirectory)" --configuration Release --no-build --verbosity minimal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=$(Agent.TempDirectory)\TestResults\Coverage\ResourcePlanningTests-TestResults.opencover.xml

On successful run, it generates code coverage fine.. but some tests are flaky and fails sometimes and pass on rerun.. so when rerun codecoverage is reported only for the flaky tests that passed on second run..

so during 1st run of 3000 tests if 2900 pass and 100 fail.. dotnet test command doesn't generate code coverage during rerun of 100 tests when all 100 pass then it generates code coverage but only for 100 tests

How to achieve proper code coverage in this case? Thanks.

Bertk commented 1 year ago

Hi, are you using coverlet.msbuild package? There is a known issue

I guess this scenario is not supported and coverage results for failed runs are not available.

Bertk commented 10 months ago

This is not a coverlet issue and I think this is related to Azure DevOps pipeline and retry failed tests scenario.

I guess there are 2 options:

MergeWith is the proposed solution

github-actions[bot] commented 7 months ago

This issue is stale because it has been open for 3 months with no activity.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 3 months with no activity.