Practice · Test design
Statement and branch coverage questions and answers
Exam-style statement and branch coverage questions, generated fresh each time, with answers computed to the ISTQB Foundation Level v4.0 definitions (section 4.3.1 and 4.3.2). Every wrong answer tells you which mistake leads to it.
What the syllabus asks for
Statement coverage is the share of executable statements that the tests run. Branch coverage is the share of branches they exercise, and branches include the true and false outcomes of every decision, so an IF without an ELSE still has a false branch that some test must take. Branch coverage subsumes statement coverage: 100% branch coverage also achieves 100% statement coverage, but not the other way round.
The questions here use short programs with IF and IF-ELSE and no loops, and the minimum number of tests is found by trying every set of paths. The cyclomatic complexity appears among the wrong answers on purpose: it is an upper bound for branch coverage, not the minimum.
What this is not
These are not questions from any ISTQB exam, and this site has no connection with ISTQB or any exam provider. Older question banks often use definitions from before version 4.0, so if an answer here disagrees with one you’ve seen elsewhere, check which syllabus it was written for. How the questions are made explains how every answer is checked.
Other techniques