-
Notifications
You must be signed in to change notification settings - Fork 392
Description
Describe the bug
Both coverlet.msbuild and coverlet.collector report 0% code coverage when running xUnit integration tests against an ASP.NET Core API using WebApplicationFactory<Program>.
The tests issue real HTTP requests via HttpClient created from the factory. Despite multiple endpoints being exercised, coverage is always reported as zero. If I disable test concurrency/parallelization in xUnit, the code coverage is calculated correctly, so the issue only occurs when the tests are executed concurrently.
To Reproduce
Repro repository: https://github.com/Bart-Med/coverlet-coverage-repro
From the repo root:
msbuild
- dotnet test Demo.Api.IntegrationTests/Demo.Api.IntegrationTests.csproj --logger trx --configuration Debug --no-restore /p:UsePackageReference=true /p:UseExternalPackageReference=true --settings coverlet.runsettings /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
collector
- dotnet test Demo.Api.IntegrationTests/Demo.Api.IntegrationTests.csproj --configuration Debug --no-restore /p:UsePackageReference=true /p:UseExternalPackageReference=true --settings Sources/coverlet.runsettings --collect:"XPlat Code Coverage"
Expected behavior
Non-zero coverage.
Actual behavior
Coverage is reported as 0% in both drivers.
Configuration (please complete the following information):
coverlet.msbuild: 6.0.4
coverlet.collector: 6.0.4
Microsoft.NET.Test.Sdk: 18.0.0
xUnit: xunit.v3 3.2.0, xunit.runner.visualstudio 3.1.5
Target Framework: net8.0
OS / Distro: windows/linux
Architecture: x64