Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

NCrunch marking excluded code as not covered.
stevehjohn
#1 Posted : Monday, October 28, 2019 10:10:26 AM(UTC)
Rank: Member

Groups: Registered
Joined: 5/30/2018(UTC)
Posts: 17
Location: United Kingdom

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
Hi,

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

See picture here:

Coverage Issue

Regards,

Steve.
Remco
#2 Posted : Monday, October 28, 2019 11:51:57 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
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.
1 user thanked Remco for this useful post.
stevehjohn on 11/6/2019(UTC)
stevehjohn
#3 Posted : Wednesday, November 6, 2019 3:21:52 PM(UTC)
Rank: Member

Groups: Registered
Joined: 5/30/2018(UTC)
Posts: 17
Location: United Kingdom

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
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.
stevehjohn
#4 Posted : Wednesday, November 6, 2019 3:45:07 PM(UTC)
Rank: Member

Groups: Registered
Joined: 5/30/2018(UTC)
Posts: 17
Location: United Kingdom

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
BTW, using method group conversion fixes the issue.

Cheers,

Steve.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.027 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download