Example statement:
if (conditionA && conditionB && conditionC && conditionD) {
return true;
}
I could write unit tests for all 2^4 combinations, but that would easily go out of hand if more conditions are added.
What should be my unit testing strategy to cover all conditions for a statement like this? Is there any other way to make the code more robust?
The way I see this scenario is 1 happy path, and 4 potential points of failure. If each condition is pivotal to allowing true to be returned, then it would be reasonable to write:
I understand it's possible to write logic that passes these checks, but actually returns true when multiple variables are false... but I really wouldn't worry about cases like that unless you're working on a spaceship or something where life / death is involved. In almost all cases, the tester is just testing that the implementation fails on the failure of any variable.