ITPEC FE Morning April 2019 Question 49

In the flowchart below, what is the minimum number of test cases that satisfies the decision condition coverage (branch coverage)?

X > 1True(X ÷ 2)XFalseA = 2 orB = 0True(X + 1)XFalse

Explanation

2 test cases — the flowchart has two independent decisions in sequence, and each test takes one branch of each.

Both processes rejoin the main line after running, so there is no loop: the chart is two if statements one after the other. Branch coverage needs the True and the False exit of every decision taken at least once, which is four exits. One test passes through both decisions and can take one exit of each, so two tests can cover all four:

  • •Test 1: X = 4, A = 2 — X > 1 is True, then A = 2 or B = 0 is True
  • •Test 2: X = 1, A = 1, B = 1 — both decisions are False

The second decision tests A and B, which the first process does not change, so any combination of exits is reachable.

Answer (b)

Why not others:

  • •(a) 1 — a single test takes only one exit of each decision, leaving the other two exits uncovered
  • •(c) 3 — one test more than needed: tests 1 and 2 already take all four exits
  • •(d) 4 — covers every True/False combination of the two decisions, which is path coverage, more than branch coverage demands

Key rule: For decisions in sequence, branch coverage needs as many tests as the largest number of exits of any one decision, here 2; counting all combinations gives path coverage instead.

System Development Technology · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.