I was just wondering about how the code coverage works in visual studio. Here is a very simple version of my scenario.
if (A || B)
{
//Do the thing
}
I have 4 unit tests to assert whether the "thing" is done or not, testing against all possible permutations of A and B like so:
- A' + B' Assert thing was not done
- A' + B Assert thing was done
- A + B' Assert thing was done
- A + B Assert thing was done
All of these tests predictably pass. The problem is that I am still getting a "partially" covered result for the if condition itself. As far as I know, I have every possibility covered. Is there something I am missing here?
Thank you in advance, feel free to redirect me if there is an answer for this already, but I could not find one. In fact, the answers I did find said that I should have 100% coverage, so I wanted to see what you guys think.
Something to Note:
I am not sure if this makes any difference, but technically A and B are comparisons of properties of 2 instances of the same class, so really the code looks like this:
if(oldObj.ValueA != newObj.ValueA || oldObj.ValueB != newObj.ValueB)
{
//do the thing
}
Hope that is enough detail, thanks again. I realize that obsessing over 100% coverage is silly, but this is mostly out of curiosity.