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

Notification

Icon
Error

Code coverage incorrect
openshac
#1 Posted : Wednesday, January 18, 2017 9:54:22 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/19/2015(UTC)
Posts: 14
Location: United Kingdom

Thanks: 6 times
Was thanked: 1 time(s) in 1 post(s)
The following code snippets give different code coverage stats:

Quote:
if (isValid) return;


Quote:
if (isValid)
{
return;
}


The first example has 100% coverage if isValid = false
The second example has <100% coverage if isValid = false

Now I appreciate some developers will say that all if statements should have braces, but we have a lot of legacy code that doesn't.

DotCover returns < 100% which is what I'd expect.
Remco
#2 Posted : Wednesday, January 18, 2017 11:34:56 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 sharing this.

Although no doubt many people will be unhappy about me saying this, this problem is by design.

NCrunch's code coverage only has line-by-line resolution. NCrunch does not separate lines into statements for more detailed analysis.

The reasons for this are as follows:
- Performance
- Implementation difficulty (the coverage tracking/merging of NCrunch is very high performance and extremely complex)
- Aggregation/UI complexity (it's hard to meaningfully show partially covered lines with markers in a way that fits with the existing model)

Given the above constraints, it is unlikely that this design will be changed in the near future.
1 user thanked Remco for this useful post.
openshac on 1/18/2017(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.022 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download