nerdexam
BCS-ISEB

ISEB-SWTINT1 · Question #39

Given the following fragment of code, how many tests are required for 100% decision coverage? discount = 0 order_quantity=0 real order_quantity if order_quantity >=20 then discount = 0.05 if…

The correct answer is A. 3. Option A (3 tests) is correct because the code contains 2 decisions (the outer if order_quantity >= 20 and the inner if order_quantity >= 100), and decision coverage requires each decision to evaluate to both TRUE and FALSE. The three test cases needed are: (1) order_quantity <…

Test Techniques

Question

Given the following fragment of code, how many tests are required for 100% decision coverage? discount = 0 order_quantity=0 real order_quantity if order_quantity >=20 then discount = 0.05 if order_quantity >=100 then discount = 0.1 end_if end_if

Options

  • A
  • B
  • C
  • D

How the community answered

(52 responses)
  • A
    71% (37)
  • B
    4% (2)
  • C
    8% (4)
  • D
    17% (9)

Explanation

Option A (3 tests) is correct because the code contains 2 decisions (the outer if order_quantity >= 20 and the inner if order_quantity >= 100), and decision coverage requires each decision to evaluate to both TRUE and FALSE. The three test cases needed are: (1) order_quantity < 20 - outer decision FALSE, inner never reached; (2) 20 ≤ order_quantity < 100 - outer TRUE, inner FALSE; (3) order_quantity ≥ 100 - both TRUE.

Option D (2) is wrong because two tests cannot cover all four decision outcomes - you'd have to leave at least one branch unexercised. Options B (4) and C (5) are wrong because they overcount; once both decisions have been driven TRUE and FALSE, coverage is complete with no additional tests needed.

Memory tip: For nested if statements, count the decisions and remember that a FALSE on the outer if "skips" the inner one entirely - so you don't need a separate test for the inner FALSE independently of the outer TRUE. That nesting is what keeps it at 3, not 4.

Topics

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

Community Discussion

No community discussion yet for this question.

Full ISEB-SWTINT1 Practice