coverlet icon indicating copy to clipboard operation
coverlet copied to clipboard

Different versions of coverlet.collector gives entirely different branch coverage

Open binoymoolayil opened this issue 3 years ago • 1 comments

I have a xunit test project which is developed using .Net core 3.1 framework(Coverlet.collector version 1..20). We have covered all the branches, but code coverage report still says some more branches need to be covered. So I changed to 1.1.0 which gives a better result. Please find the branch coverage for various versions. What could be the reason for a such difference. Which is the correct version to be used to .net core 3.1 framework?

.Net Framework Coverlet.collector Test Sdk xunit Total branches Covered Branch coverage comments
.Net core 3.1 1.1.0 16.5.0 2.4.0 600 581 96.82 downgraded coverlet.collector version
.Net core 3.1 1.2.0 16.5.0 2.4.0 661 493 74.58 Default project versions
.Net core 3.1 3.0.0 16.5.0 2.4.0 222 187 84.23  
.Net core 3.1 1.2.1 16.5.0 2.4.0 226 189 83.62  
.Net core 3.1 3.1.2 17.1.0 2.4.1 222 187 84.23  

binoymoolayil avatar Aug 23 '22 12:08 binoymoolayil

You should always use the last version of coverlet available, we fix bugs and edge case in coverage instrumentation. Unfortunately what you see in your source file is not the real code, we instrument at IL level and every time compilers ship new feature we need to work a bit to adapt to the new pattern, so it's normal for coverlet have different level of coverage % in any versioin, we aim to be close as possible and we improved moving on(for sure 1.1.0 is too old I wasn't a maintainer when that version was shipped I think 😄).

And you should check also the report to see if coverlet is doing something wrong...the % as-is is not super useful if not for fail the CI.

MarcoRossignoli avatar Aug 25 '22 08:08 MarcoRossignoli

I'm closing this as the question seems to be answered. Feel free to reopen.

daveMueller avatar Apr 10 '23 21:04 daveMueller