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

Notification

Icon
Error

Properties and false code coverage
4rchie
#1 Posted : Monday, December 17, 2012 4:12:15 PM(UTC)
Rank: Member

Groups: Registered
Joined: 10/12/2011(UTC)
Posts: 27
Location: Poland

Thanks: 2 times
Was thanked: 6 time(s) in 6 post(s)
I have a assembly with load of not testes classes with auto properties. In NCrunch metrics they all get 100% coverage which is totally untrue. When i convert them to properties with backing field it all works all right.

Such props should be marked black/green/ and half green when only getter is tested but not setter (and vice versa).

The same mechanizm goes for one line ifs, they should get half green dot when not all branches are coverted.

Regars,
4rchie
1 user thanked 4rchie for this useful post.
albertomonteiro on 9/6/2013(UTC)
Remco
#2 Posted : Monday, December 17, 2012 8:15:56 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Hi Archie -

As the compiler doesn't emit debugging information for auto properties, they are essentially invisible to tools such as NCrunch. The metrics view will report 100% code coverage on a source file that contains no code (I'm willing to discuss the correctness of this as I understand that it may be misleading).

However, I agree with your analysis. If a technical approach can be found to solve this problem and introduce coverage markers to auto properties, this would make sense.


Cheers,

Remco
4rchie
#3 Posted : Monday, December 17, 2012 9:06:20 PM(UTC)
Rank: Member

Groups: Registered
Joined: 10/12/2011(UTC)
Posts: 27
Location: Poland

Thanks: 2 times
Was thanked: 6 time(s) in 6 post(s)
You can look for it on an IL level. Tools like NCover finds this kinds of stuff and I strongly believe that you can do it as well.

The same goes to ? and ?? operators

Consider folowing:

[Test]
public void SomeTest()
{
var result = GetResult(true);
Assert.AreEqual("Covered branch",result);
}

private string GetResult(bool condition)
{
return condition ? "Covered branch" : "uncovered branch";
}

you will get all green dots even though that the half of the GetResult is actually not covered.
1 user thanked 4rchie for this useful post.
albertomonteiro on 9/6/2013(UTC)
Remco
#4 Posted : Tuesday, December 18, 2012 6:23:34 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Sorry - I meant that the debugging information constraints were around auto-properties. You are absolutely right about the different branches being fully detectable using more granular instrumentation at IL level - this is certainly possible.
albertomonteiro
#5 Posted : Friday, September 6, 2013 6:59:40 PM(UTC)
Rank: Member

Groups: Registered
Joined: 5/28/2012(UTC)
Posts: 17
Location: Fortaleza, Ceara - Brasil

Thanks: 11 times
Was thanked: 3 time(s) in 3 post(s)
So will NCrunch support half green indicator when using ?? operator?
In my application I use "??" operator sometimes, and I would like to be warned when still need to cover.
I am using version 1.46.0.20.
Remco
#6 Posted : Friday, September 6, 2013 11:53:03 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Hi -

I'm afraid that there are no firm plans yet on when this will happen, if it actually ever will happen.

This is because the complexity involved in adding an extra dimension to the code coverage tracking is too high for this feature to be feasible. Currently no planned solution exists that will allow the engine to meet an acceptable standard of performance.


Sorry.


Cheers,

Remco
1 user thanked Remco for this useful post.
albertomonteiro on 9/27/2013(UTC)
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.048 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download