nerdexam
BCS-ISEB

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…

Test Techniques

Question

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 else Biggest_diension = length If height>length Then Biggest_dimension = height End_if End_if

Options

  • A3
  • B4
  • C2
  • D1

How the community answered

(44 responses)
  • A
    5% (2)
  • B
    84% (37)
  • C
    2% (1)
  • D
    9% (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

#decision coverage#branch coverage#white-box testing#control flow

Community Discussion

No community discussion yet for this question.

Full ISEB-SWTINT1 Practice