Daily Usage Issues

NCrunch marking excluded code as not covered.

Started by stevehjohn on 2,488 views

Hi,

NCrunch seems to be ignoring ExcludeFromCodeCoverage attribute for one line within a method.

See picture here:

[img=http://www.outsidecontextproblem.com/temp-img/Coverage-Issue.png]Coverage Issue[/img]

Regards,

Steve.

Edited

Hi Steve, thanks for sharing this issue.

This is a known limitation caused by the way the compiler generates code. The line not being considered by ExcludeFromCodeCoverage is a lambda expression that is physically compiled to a different method. Because the method is separate, it does not have the attribute.

The last time I checked, the VS runner itself also suffers from this problem.

Although it IS technically possible for us to fix this by inferring the attribute on the compiler generated method, it takes some processing to do so with a considerable performance penalty that would affect all instrumentation regardless of whether the attribute is actually used. For this reason, it's better simply not to fix the problem as the solution is worse than the problem itself. If this is causing you problems, my recommendation is to use the NCrunch code coverage suppression comments instead or to consider a different method structure.

Edited

Hi,

Thanks for the response, sorry for the delay in replying, the notification went into my spam folder.

I suspected it might be something like that. It's not really causing a problem as such. It did lower the coverage % on out CI server though. I'll see how I can restructure the constructor.

Thanks,

Steve.
BTW, using method group conversion fixes the issue.

Cheers,

Steve.

Post a reply

Log in to reply.