Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What .Net coverage tools support "condition coverage"? [closed]

I am just starting with code coverage tools (primarily in C#). So far I have tested out NCrunch and DotCover.

They both seem to do a good job with branch and function coverage, but I can't tell for sure if they're doing conditional coverage. For example, in some code I'm testing, the following shows as covered so long as there is at least one path through (or am I wrong about that?). However, it seems to me that it should only be covered if both logical paths through the code are covered.

if (item != "")
{
    glc.AddGrayListItem(GrayListTypeEnum.BlackList, item);
}

What I'd like to know is if DotCover or NCrunch (or any other tool for C#) will tell me that this isn't covered unless both cases (item != null) and (item == null) are tested.

I've looked on various sites and can't seem to find a definitive answer about whether either of these tools works this way, or if there's another tool that does work this way. Do any of you have definitive information about what types of coverage various code-coverage tools do or do not supply?

like image 493
Joe Avatar asked Mar 20 '23 22:03

Joe


2 Answers

The current version of OpenCover will does cover this in branch coverage metrics:

enter image description here

like image 98
Nathan Bedford Avatar answered Apr 26 '23 04:04

Nathan Bedford


In case others are interested in an answer to this question... NCover is the only tool I have found that does the job so far (2017). I have checked Visual Studio Enterprise Code Coverage, NCrunch, Resharper dotCover, OpenCover and NDepend. None of them supported the Condition Coverage case you asked for. NCover shows a 66.67% condition coverage if the unit test doesn't cover both true and false cases in your example.

like image 21
user1460126 Avatar answered Apr 26 '23 05:04

user1460126