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

Notification

Icon
Error

NCrunch not showing correct color "balls" in the gutter
larsw
#1 Posted : Thursday, January 3, 2013 8:25:39 AM(UTC)
Rank: Member

Groups: Registered
Joined: 11/22/2011(UTC)
Posts: 15
Location: Oslo, Norway

Was thanked: 3 time(s) in 3 post(s)
Hi and happy NY,


Re.
NCrunch color problem

Shouldn't all the lines for this statement be colored as green?

Regards,

Lars Wilhelmsen
--larsw
Remco
#2 Posted : Thursday, January 3, 2013 9:55:10 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 Lars,

Thanks for posting and happy new year!

It is difficult to tell whether the lines should be green or not, as this would depend upon the execution manner of this expressions in this statement.

With the exception of the first line of the statement, the code shown above will not execute until it is hit by an enumerator of some kind. The lambda expressions form an enumerable for which the execution is deferred until later in the program.

You'll probably find that if you put a .ToList() at the end of the statement, all the lines shown above will turn green. I hope this makes sense.


Cheers,

Remco
larsw
#3 Posted : Thursday, January 3, 2013 3:08:24 PM(UTC)
Rank: Member

Groups: Registered
Joined: 11/22/2011(UTC)
Posts: 15
Location: Oslo, Norway

Was thanked: 3 time(s) in 3 post(s)
Hi again Remco,

I'm fully aware of the deferred nature of executing chained LINQ expressions on enumerables - but what my screenshot does not show (sorry for that), is that the enumerable is in fact
iterated over further down in the code file, so the code is in fact run (I've also verified it in the debugger).

I will try to isolate a test case.

--larsw
--larsw
Remco
#4 Posted : Thursday, January 3, 2013 10:31:37 PM(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)
Sorry. It may be that this is a mapping problem then. If you're able to put together a complete sample, I'd really like to take a look!


Cheers,

Remco
larsw
#5 Posted : Friday, January 4, 2013 8:34:05 AM(UTC)
Rank: Member

Groups: Registered
Joined: 11/22/2011(UTC)
Posts: 15
Location: Oslo, Norway

Was thanked: 3 time(s) in 3 post(s)
Hi again,

After a deeper investigation, it seems that it is my test rig that left out enumerating an input in a mock (e.g. I forgot to do something about the input, I only returned a mocked return value).
Fixing that and the balls turned green :)

--larsw
--larsw
Remco
#6 Posted : Friday, January 4, 2013 10:24:23 PM(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)
Great to hear! Thanks for letting me know :)
larsw
#7 Posted : Friday, January 11, 2013 8:18:05 AM(UTC)
Rank: Member

Groups: Registered
Joined: 11/22/2011(UTC)
Posts: 15
Location: Oslo, Norway

Was thanked: 3 time(s) in 3 post(s)
Hi again Remco,

Had a discussion with a colleague where he points out an interesting thing; in the example code above,
if I had not split the chained statement over multiple lines (e.g. I had inlined it all on one line) the ball would go green,
even though not all of the code had been exercised.

May it be the same case with conditional expressions?

if (foo() || bar() || baz()) <-- if foo() returns true, then bar() and baz() would not be called at all.
{
// ...
}

?

I know that the built-in Code Coverage functionality in Visual Studio can color lines as partially covered - might this be something
to look into for the next release?

--larsw
--larsw
Remco
#8 Posted : Friday, January 11, 2013 8:53:53 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 Larsw,

You are absolutely correct. This is caused by the limited resolution in which NCrunch captures the code coverage data during execution - it basically handles it on a line-by-line basis rather than statement-by-statement basis.

There have been a few suggestions on this forum around how to visualise lines as partially covered, for example, by making the coverage markers appear half full.

I'd like to address this issue, although at this stage I'm not yet sure as to the feasibility. The NCrunch mapping algorithm is a fairly extreme piece of code and it may be difficult to keep it performing adequately with a new dimension added to it. The solution to this may live on the NCrunch backlog to be looked at as part of a long term plan.


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