ISEB-SWTINT1 · Question #22
Given the following fragment of code, how many tests are required for 100% decision coverage? If width > lenth then Biggest_diension = width If height > width then biggest_dimension = height end_if…
The correct answer is B. 4. Option B (4 tests) is correct because there are three distinct decision points in this code - width > length, height > width (in the true branch), and height > length (in the else branch) - and each must evaluate to both TRUE and FALSE for 100% decision coverage. Critically…
Question
Options
- A3
- B4
- C2
- D1
How the community answered
(44 responses)- A5% (2)
- B84% (37)
- C2% (1)
- D9% (4)
Explanation
Option B (4 tests) is correct because there are three distinct decision points in this code - width > length, height > width (in the true branch), and height > length (in the else branch) - and each must evaluate to both TRUE and FALSE for 100% decision coverage. Critically, decisions 2 and 3 live in mutually exclusive branches, so you need at least 2 tests inside each branch: one where the inner condition is true, one where it's false. That forces a minimum of 4 tests total.
Why the distractors fail:
- C (2) only gives you one path through the outer if and one through the else, leaving the inner decisions each tested only once (only TRUE or only FALSE, not both).
- A (3) is tempting because there are 3 decisions, but the mutual exclusivity of the two inner decisions means you can't share tests between them - you need a dedicated pair for each nested branch.
- D (1) can only traverse one execution path, covering a fraction of the decisions.
Memory tip: When an if/else contains nested conditions in both branches, those nested decisions can never share a test. Count the leaf-level paths: here there are 4 (T+T, T+F, F+T, F+F), and that count directly equals the minimum tests needed for full decision coverage.
Topics
Community Discussion
No community discussion yet for this question.