Collecting code coverage prevents all test discovery on net472 only
See original GitHub issueThis repros locally and in Azure Pipelines builds.
git clone https://github.com/AArnott/Xunit.StaFact.git
cd Xunit.StaFact\src
git checkout 6d1a5e6023f612ad00d2e00f5204f362dc0a71ce
dotnet test --filter "TestCategory!=FailureExpected" -v n /p:CollectCoverage=true
Notice how net472 runs 0 tests and reports:
+---------------+------+--------+--------+
| Module | Line | Branch | Method |
+---------------+------+--------+--------+
| Xunit.StaFact | 0% | 0% | 0% |
+---------------+------+--------+--------+
+---------+------+--------+--------+
| | Line | Branch | Method |
+---------+------+--------+--------+
| Total | 0% | 0% | 0% |
+---------+------+--------+--------+
| Average | 0% | 0% | 0% |
+---------+------+--------+--------+
While the netcoreapp targets report non-zero results:
+---------------+--------+--------+--------+
| Module | Line | Branch | Method |
+---------------+--------+--------+--------+
| Xunit.StaFact | 86.44% | 62.19% | 78.33% |
+---------------+--------+--------+--------+
+---------+--------+--------+--------+
| | Line | Branch | Method |
+---------+--------+--------+--------+
| Total | 86.44% | 62.19% | 78.33% |
+---------+--------+--------+--------+
| Average | 86.44% | 62.19% | 78.33% |
+---------+--------+--------+--------+
In fact simply comparing the output of these two commands shows that the mere collection of code coverage is what blocks test discovery:
dotnet test --filter "TestCategory!=FailureExpected" /p:CollectCoverage=true -f net472
dotnet test --filter "TestCategory!=FailureExpected" -f net472
Issue Analytics
- State:
- Created 4 years ago
- Comments:24 (3 by maintainers)
Top Results From Across the Web
Use code coverage for unit testing - .NET
Code coverage is a measurement of the amount of code that is run by unit tests - either lines, branches, or methods. As...
Read more >Code Coverage Results are incomplete (again)
Tests (net472) or C. If I run A and B at the same time, it fails. Only code covered by B gets recorded....
Read more >Code Coverage is Finally Easy in .Net Core
A couple of months ago calculating code coverage on the command line was quite challenging in ASP.Net Core. Fortunately, as of last month ......
Read more >Problems with .NET unit testing
Unit tests work fine for me in NUnit 3.12.0 however any time I try to run tests with coverage, I get "Exit code...
Read more >Code Coverage vs Test Coverage
Code coverage and test coverage are key metrics in software testing strategies that measure the codebase's effectiveness.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m getting similar results with this project: https://github.com/saucecontrol/Blake2Fast/tree/azure-coverage
What I’ve found is that when I run locally, I get correct results with netfx target on 32-bit
with the following runsettings:
However, if I switch to
<TargetPlatform>x64</TargetPlatform>
, I get 0% coverage.On Azure Pipelines, I get 0% coverage under either config.
The netcore targets are correct no matter how I run.
will do.