question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Collecting code coverage prevents all test discovery on net472 only

See original GitHub issue

This 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:open
  • Created 4 years ago
  • Comments:24 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
saucecontrolcommented, Jan 26, 2020

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

dotnet test tests\Blake2.Test -c Coverage -s tests\runsettings --logger trx

with the following runsettings:

<RunSettings>
    <RunConfiguration>
        <TargetPlatform>x86</TargetPlatform>
        <DisableAppDomain>true</DisableAppDomain>
    </RunConfiguration>
</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.

0reactions
jasellscommented, Mar 13, 2022

will do.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found