cyclomatic complexity, number of tests for full coverage?
Wikipedia says that following program has cyclomatic complexity of 3 Given that formula is V-E+2P, the answer is definitely 3 (9 - 8 + 2*1 = 3). Alternative definition says: Number of tests to cover all lines. But I see that only two tests are enough to cover 100% of lines. Test1 - always choosing left. (straight down) Test2 - always branching to the right once (or looping once) What am I missing? Why should there be 3 tests?

Wikipedia says that following program has cyclomatic complexity of 3
Given that formula is V-E+2P
, the answer is definitely 3 (9 - 8 + 2*1 = 3
).
Alternative definition says: Number of tests to cover all lines.
But I see that only two tests are enough to cover 100% of lines.
- Test1 - always choosing left. (straight down)
- Test2 - always branching to the right once (or looping once)
What am I missing? Why should there be 3 tests?