What does Branch Coverage mean?
What does Branch Coverage mean?
I've got a method which is 100% covered by tests, here it is with "max visit count" in brackets before each line:
public ActionResult ResetPassword(string email, string token)
{
(4) var user = this.userService.Get(email);
(4) if (user != null && user.PasswordResetRequestToken == token)
{
(2) userService.ResetPassword(user);
(2) return View("PasswordReset_Success");
}
else
{
(2) return View("PasswordReset_Fail");
}
}
Im told by NCover that this method has "100% method coverage" but only "75% branch coverage with 1 unvisited branch point" what does this mean?
RE: What does Branch Coverage mean?
You never "fall out" of the method, so the last branch (the last } ) is never hit.
There isn't really anything you can do about that other than just ignore it, or to set a local value and return at the end.
Does that help?
Joe Feser
RE: What does Branch Coverage mean?
Ahhhh i see, thanks :)
RE: What does Branch Coverage mean?
I cannot reproduce this behavior. I always get a Branch Coverage of 100%.
Peter
I have NCover 3.2.4