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

Notification

Icon
Error

Code coverage results are strange when using conditional
strike2867
#1 Posted : Wednesday, December 11, 2013 4:09:08 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/11/2013(UTC)
Posts: 8
Location: United States of America

Using the following test code

public int TrySomething(int x)
{
int z = x > 5 ? 2 : 3;
return z;
}

[TestMethod]
public void TestTrySomething()
{
var actual = TrySomething(10);
Assert.AreEqual(2, actual);
}

VS code coverage shows it as 80% covered in VS 2012 but we get a green circle as that row being covered. I'd expect some kind of mixed circle instead of just showing as fully covered.
Remco
#2 Posted : Wednesday, December 11, 2013 10:29:02 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi -

Thanks for sharing this. Right now NCrunch's code coverage resolution works to the line only (not to the statement), so as you've described, there is granularity that is lost here in the coverage reporting.

This has been an often requested feature although at this stage I haven't yet found a way to implement it. The complexity of the NCrunch algorithm that maps code coverage is staggeringly complex, and getting it to perform acceptably with statement level coverage is a fairly epic challenge.

I appreciate you mentioning this though, as it does help to underscore the need.


Cheers,

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.025 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download