Coverage incorrectly reported as 0% for integration tests
See original GitHub issueI have a open source project that is using Coverlet to calculate test coverage.
The coverage seems to work correctly for unit tests.
However, coverage doesn’t get reported for integration tests.
The integration tests I’m running use Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory
to bring up a ASP.Net Web API application in memory and then uses a HTTP client to make API calls to this in-memory application.
However, none of the code executed is being included in the coverage. It doesn’t even get the top-level controllers that get hit when the HTTP request is executed.
See this pull request for more details.
The dotnet test
command is in the GitHub Action (dotnet test ./Lewee-CI.sln --configuration Release --no-build --collect "XPlat Code Coverage" --results-directory ./coverage
).
Issue Analytics
- State:
- Created 6 months ago
- Comments:12
Top GitHub Comments
I didn’t have time to check yet, I’m pretty busy this period.
let’s see if @daveMueller @petli has got some fresh ideas.
I feel rather embarrassed.
The tests that were supposed to contribute to coverage (in both my original repository and the experiment repository) were using BDDfy, but I wasn’t adding the
BDDfy()
method call at the end of my tests 🤦The super-fast speed of execution of the tests should have been a tell-tale sign.
I made the appropriate changes in my experiment repository and the coverage looked correct.
Sorry about the hassle.