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.

Coverage results aren't stable

See original GitHub issue

We (dotnet/runtime) recently switched from coverlet’s global tool to dotnet test with the coverlet data collector. With the data collector driver I just noticed that the produce coverage results file isn’t stable and varies between multiple invocations.

See the generated reports for five invocations of C:\git\runtime\src\libraries\System.Text.RegularExpressions\tests>dotnet test -f netcoreapp5.0 /p:Coverage=true: coverage-RegularExpressions.zip

Something that immediately points out is the difference in the summary:

  <Summary numSequencePoints="10557" visitedSequencePoints="7413" numBranchPoints="4982" visitedBranchPoints="3491" sequenceCoverage="70.21" branchCoverage="70.07" maxCyclomaticComplexity="5476" minCyclomaticComplexity="5476" visitedClasses="53" numClasses="55" visitedMethods="727" numMethods="817" />
  <Summary numSequencePoints="10557" visitedSequencePoints="7431" numBranchPoints="4982" visitedBranchPoints="3516" sequenceCoverage="70.38" branchCoverage="70.57" maxCyclomaticComplexity="5476" minCyclomaticComplexity="5476" visitedClasses="53" numClasses="55" visitedMethods="727" numMethods="817" />
  <Summary numSequencePoints="10557" visitedSequencePoints="8415" numBranchPoints="4982" visitedBranchPoints="4107" sequenceCoverage="79.71" branchCoverage="82.43" maxCyclomaticComplexity="5476" minCyclomaticComplexity="5476" visitedClasses="54" numClasses="55" visitedMethods="768" numMethods="817" />
  <Summary numSequencePoints="10557" visitedSequencePoints="8181" numBranchPoints="4982" visitedBranchPoints="4029" sequenceCoverage="77.49" branchCoverage="80.87" maxCyclomaticComplexity="5476" minCyclomaticComplexity="5476" visitedClasses="54" numClasses="55" visitedMethods="758" numMethods="817" />
  <Summary numSequencePoints="10557" visitedSequencePoints="8376" numBranchPoints="4982" visitedBranchPoints="4092" sequenceCoverage="79.34" branchCoverage="82.13" maxCyclomaticComplexity="5476" minCyclomaticComplexity="5476" visitedClasses="54" numClasses="55" visitedMethods="768" numMethods="817" />

VSTest reports the same number of tests being discovered and executed for all the five runs:

Test Run Successful.
Total tests: 7204
     Passed: 7204

I’m wondering if hit points aren’t correctly propagated back to the hits file?

cc @MarcoRossignoli @sharwell @petli @stephentoub

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ViktorHofercommented, May 6, 2020

I didn’t roll anything back 😃 You can try it in dotnet/runtime master with:

build.cmd clr+libs -rc Release
dotnet test -f net5.0 /p:Coverage=true src\libraries\System.Text.RegularExpressions\tests\
1reaction
ViktorHofercommented, May 5, 2020

So the instrumentation is working as expected as the numSequencePoints, numBranchPoints, maxCyclomaticComplexity, minCyclomaticComplexity, numClasses and numMethods values are the same.

The visited ones differ largely…

Read more comments on GitHub >

github_iconTop Results From Across the Web

unit testing - Unexpected Code Coverage Reduction
The answer is quite simple: use absolute numbers, not percent. What is more important then coverage percent are number of untested functions and ......
Read more >
Code Coverage API Plugin
By default, code coverage results are only recorded for stable or unstable builds, but not for failed builds: code coverage results might be...
Read more >
Coverage is not strongly correlated with test suite ...
I use coverage to find code with no tests all at, and write tests for that code. But once it is "covered" the...
Read more >
Code coverage data is not automatically refreshed : WI-25513
When I work with code coverage reporting (Tools -> Show Code Coverage Data) the IDE does not refresh the Coverage tool window after...
Read more >
Customizing Code Coverage Analysis - Visual Studio
Any previous code coverage results and code coloring aren't ... Static native instrumentation is more stable and it is recommended.
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