Statement coverage
The percentage of executable statements exercised by a test suite, used as a white-box coverage measure.
Syllabus chapters: 4
Sources: ISTQB® Certified Tester Foundation Level syllabus 4.0.1 and the official ISTQB® Glossary. Glossary content © International Software Testing Qualifications Board; source: glossary.istqb.org.
Related terms
Statement coverage in a practice question
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 test suite achieves 100% statement coverage of a module. In production the module still fails with a division by zero, which occurs only when a denominator is set to zero. Which explanation is correct?
- Exercising a statement does not detect defects in all cases, and data-dependent defects can survive full statement coverage
- 100% statement coverage cannot in fact have been reached, because the failing statement was clearly never executed
- 100% statement coverage ensures that the decision logic was tested, so the defect must lie in a different module
- Coverage was measured wrongly: statements exercised should be divided by the total number of branches
Show answer
- Correct answer: Exercising a statement does not detect defects in all cases, and data-dependent defects can survive full statement coverageThe statement was executed, but a data-dependent defect need not show itself.
- 100% statement coverage cannot in fact have been reached, because the failing statement was clearly never executedThe statement was executed; full statement coverage is what puts the defect on a covered line.
- 100% statement coverage ensures that the decision logic was tested, so the defect must lie in a different module100% statement coverage does not ensure that all the decision logic has been tested.
- Coverage was measured wrongly: statements exercised should be divided by the total number of branchesStatement coverage divides exercised statements by total executable statements.
When 100% statement coverage is achieved, every executable statement has been exercised at least once, so a statement containing a defect will have been executed. However, exercising a statement with a test case will not detect defects in all cases; the syllabus gives a division by zero that fails only when the denominator is zero as its example of a data-dependent defect. 100% statement coverage also does not ensure that all the decision logic has been tested.
Syllabus section 4.3.1
Original PrepBench practice material, not official exam questions or exam dumps. PrepBench is independent and is not affiliated with or endorsed by ISTQB®.