opencover icon indicating copy to clipboard operation
opencover copied to clipboard

Branch coverage problem in async functions.

Open nripendra opened this issue 8 years ago • 2 comments

When working with async functions, branch coverage report is giving wrong result.

My Framework

  • [x] .NET Core 1.0.0

My Environment

  • [x] Windows 8.1
  • [x] Windows 10

I have already...

  • [x] repeated the problem using the latest stable release of OpenCover.
  • [x] reviewed the usage guide and usage document.
  • [ ] have looked at the opencover output xml file in an attempt to resolve the issue.
  • [ ] reviewed the current issues to check that the issue isn't already known.

My issue is related to (check only those which apply):

  • [ ] no coverage being recorded
  • [ ] 32 or 64 bit support
  • [ ] feature request

Expected Behavior

All my code is covered, so my branch coverage should be 100%. Probably opencover is tripping over compiler generated code.

Actual Behavior

branch-problem

Steps to reproduce the problem:

nripendra avatar Jan 24 '17 12:01 nripendra

This is happening to me to with an .NET 4.5.1 project. I'm assuming this is related to challenges related to the compiler-generated code too.

@sawilde do you have any insight that you can share? Amazing product btw.

nathanbedford avatar Feb 10 '18 01:02 nathanbedford

@nathanbedford it is due to compiler generated code - this is the problem with using branch coverage based on IL branches especially with all the new keywords such as async that do a lot of code generation around those keywords. We did try to add exclude sequences for some cases but it was a constantly moving target and not a battle I decided to fight anymore (I found it had little value).

The alternative would be to used source code analysis to weave in the IL coverage at runtime or to choose which branches to instrument but not had the time to explore that to its fullest.

sawilde avatar Mar 06 '18 23:03 sawilde