CTFL 4.3.2: Explain branch testing
K2Syllabus section 4.3.2
3 original PrepBench practice questions for learning objective 4.3.2 of the CTFL 4.0 syllabus. Try the examples below and check each answer against its syllabus reference.
Practice questions
Question 1
A team's test suite exercises both outcomes of every if-then decision in a module as well as every unconditional transfer of control. What can the team conclude about the module's coverage?
- 100% statement coverage is reached, but branch coverage may still be below 100%
- 100% branch coverage is reached, and therefore 100% statement coverage as well
- 100% branch coverage is reached, but statement coverage may still be below 100%
- Both figures are necessarily equal, since every branch contains exactly one statement
Show answer
- 100% statement coverage is reached, but branch coverage may still be below 100%This reverses the subsumption: full statement coverage does not imply full branch coverage.
- Correct answer: 100% branch coverage is reached, and therefore 100% statement coverage as wellAll branches are exercised here, and full branch coverage also gives full statement coverage.
- 100% branch coverage is reached, but statement coverage may still be below 100%Full branch coverage cannot leave statements unexercised, because it subsumes statement coverage.
- Both figures are necessarily equal, since every branch contains exactly one statementBranches and statements are different coverage items, and the syllabus states no such equality.
When 100% branch coverage is achieved, all branches in the code, unconditional and conditional, are exercised by test cases; conditional branches typically correspond to the true or false outcome of an if-then decision. Branch coverage subsumes statement coverage: any set of test cases achieving 100% branch coverage also achieves 100% statement coverage, but not vice versa.
Syllabus section 4.3.2
Question 2
A team's test suite achieves 100% branch coverage of a module. A colleague asks whether statement coverage still has to be measured separately. What follows?
- Yes, because the two measures count unrelated coverage items and neither implies the other
- Yes, because 100% branch coverage can still leave some executable statements unexercised
- No, because statement coverage subsumes branch coverage and so has been reached as well
- No, because branch coverage subsumes statement coverage, so 100% statement coverage follows
Show answer
- Yes, because the two measures count unrelated coverage items and neither implies the otherThe syllabus states explicitly that one of the two subsumes the other.
- Yes, because 100% branch coverage can still leave some executable statements unexercisedFull branch coverage exercises every branch, and so every executable statement.
- No, because statement coverage subsumes branch coverage and so has been reached as wellThis reverses the subsumption: statement coverage does not imply branch coverage.
- Correct answer: No, because branch coverage subsumes statement coverage, so 100% statement coverage followsBranch coverage subsumes statement coverage, so it follows automatically.
Branch coverage subsumes statement coverage. Any set of test cases achieving 100% branch coverage also achieves 100% statement coverage, but not the other way round. Measuring statement coverage separately therefore adds nothing once full branch coverage has been demonstrated.
Syllabus section 4.3.2
Question 3
What must be exercised to achieve 100% branch coverage of a test object?
- Each executable statement in the code, at least once
- Only every unconditional transfer of control in the code
- Every branch, including unconditional and conditional transfers of control
- Only the true and false outcomes of every if decision
Show answer
- Each executable statement in the code, at least onceThis is statement coverage; 100% statement coverage does not ensure 100% branch coverage.
- Only every unconditional transfer of control in the codeThis omits all conditional transfers of control.
- Correct answer: Every branch, including unconditional and conditional transfers of controlBranch coverage includes every unconditional and conditional transfer.
- Only the true and false outcomes of every if decisionThis omits unconditional branches and non-binary outcomes such as switch/case branches.
A branch is a transfer of control between two nodes in the control-flow graph. Achieving 100% branch coverage requires exercising all unconditional and conditional branches. Conditional branches include true and false outcomes of if decisions, switch/case outcomes, and loop exit or continuation decisions. Branch coverage includes statement coverage.
Syllabus section 4.3.2
Original PrepBench practice material, not official exam questions or exam dumps. PrepBench is independent and is not affiliated with or endorsed by ISTQB®.