My recollection from McCabe’s work on this subject is that you consistently generate the base paths, changing one condition at a time, and only changing the last condition, until you can change any new conditions.
Suppose we start with FF, which is the shortest path. Following the algorithm, we will change the latter, if in the chain we get FT. We examined the second, if now, that is: if there was an error in the second case, if our two tests paid attention to what happened when the second if statement suddenly started to run, otherwise our tests would not work or our code could not be verified. Both features suggest that our code needs to be refined.
Covering FT, we return one node to the path and change the first T to F. When constructing the base paths, we change only one condition at a time. So, we are forced to leave the second, if the same, yielding ... TT!
We stay with these basic paths: {FF, FT, TT}. What address have you raised.
But wait, you say that if an error occurs in the case of TF? Answer: we should have noticed this between two of the three other tests. Think about it:
- Second, if you already had the opportunity to demonstrate your influence on the code, regardless of any other changes in program execution using the FF and FT tests.
- The first, if I had the opportunity to demonstrate my independent effect from FT to TT.
We could start with the TT case (the longest way). We would have reached several different base paths, but they would still execute each if statement independently.
Note that in your simple example, there is no linearity in the conditions of the if statements. Linearity cripples the generation of the base path.
In short : basic path testing, performed systematically, avoids the problems you think you have. The base path test does not tell you how to write testable code. (TDD does this.) Moreover, testing the path does not tell you what statements you need to make. This is your job as a person.
Source : this is my research area, but I read McCabe's article on this particular subject a few years ago: http://mccabe.com/pdf/mccabe-nist235r.pdf