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

Notification

Icon
Error

Coverage issue with lambdas / xUnit?
nuggetboy
#1 Posted : Sunday, November 22, 2015 3:02:57 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/8/2014(UTC)
Posts: 2
Location: United States of America

I noticed that the last line of xUnit Assert.Throws lambdas are being detected as untested:
No coverage on last line of lambda

I can work around this by pulling up the last line with brace and parens like so:
Workaround

But that seems dumb. Am I doing something wrong here? It seems like this should either be detected as covered or excluded from coverage.
Remco
#2 Posted : Sunday, November 22, 2015 3:15:32 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, thanks for posting.

This line is marked as not covered by NCrunch - because it is physically not being executed at runtime.

When SomeException is thrown, the exception bubbles up the call stack and any code after it is inside the scope is not executed. You'll notice that if you put a breakpoint on this line of code, it will never be touched.

There is no way for NCrunch to exclude such a line of code automatically without attempting to read into your code to understand what it does. Rather than try to make guesses about the intention of the code based on how it is structured, NCrunch simply displays the behaviour as it physically is.

If this is making a mess of your metrics, I'd suggest excluding it from the metrics calculation by marking it with //ncrunch: no coverage
nuggetboy
#3 Posted : Sunday, November 22, 2015 5:07:38 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/8/2014(UTC)
Posts: 2
Location: United States of America

Got it! I'll use the "//ncrunch: no coverage" tip you gave.

Thanks for the reply, Remco.
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.026 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download