coverlet icon indicating copy to clipboard operation
coverlet copied to clipboard

Don't track branch coverage for Debug.Assert

Open hughbe opened this issue 6 years ago • 8 comments

E.g. https://ci.dot.net/job/dotnet_corefx/job/master/job/code_coverage_windows/Code_Coverage_Report/System.Collections_BitArray.htm image

Doesn't seem very useful as we don't expect this to happen

hughbe avatar Dec 08 '18 08:12 hughbe

The whole System.Diagnostics.Debug type can be excluded with the --exclude switch. We can definitely do that in corefx but I'm not sure if @tonerdo wants that set globally.

ViktorHofer avatar Dec 10 '18 15:12 ViktorHofer

I'm adding /P:Exclude="[*]System.Diagnostics.Debug" but doesn't seem to work - doesn't exclude mean "don't check coverage for this class" rather than "don't check anything calling this class"?

hughbe avatar Dec 17 '18 13:12 hughbe

Oh you are right but wouldn't/shouldn't a) also imply b)?

ViktorHofer avatar Dec 17 '18 13:12 ViktorHofer

Apparently not!

hughbe avatar Dec 17 '18 14:12 hughbe

Excluding a class means that non of the methods belonging to that class are instrumented. It's a non-trivial amount of work to have that exclusion rule apply the usages of the class itself

tonerdo avatar Dec 17 '18 21:12 tonerdo

I also encountered this problem.

sungam3r avatar Feb 03 '22 22:02 sungam3r

Hi folks. This is not an issue with Debug.Assert at all. The issue is && operator inside it. You can switch && to & to get full coverage. Confirmed here https://github.com/graphql-dotnet/parser/pull/242

sungam3r avatar Feb 11 '22 00:02 sungam3r