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?
The current version of OpenCover will does cover this in branch coverage metrics:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With