Software Development and Project Management

The truth values of a, b and c can be chosen independently of each other. For the code 'if (a) { S1; } if (b) { S2; } if (c) { S3; }', what is the minimum number of test cases needed to achieve branch coverage (executing both the true and false outcomes of every decision at least once)?

  1. A1
  2. B2
  3. C8
Show answer and explanation

Answer: B. 2

Each of the three decisions must be taken both ways, true and false. With the two test cases (a, b and c all true) and (all false), the true and false outcomes of each decision are each executed once, so the minimum is 2. A single test case (all true) executes all the statements S1 to S3 and so achieves statement coverage, but the false branches (the paths that do nothing and move on) are not executed. 8 is the number of all 2³ = 8 combinations of true and false.

  • A. A single all-true run achieves statement coverage, but the false branch of each decision is never executed.
  • B. Correct. The all-true and all-false runs take each decision both ways once.
  • C. This is the number of all 2³ = 8 combinations of true and false; branch coverage does not require that many.
Practice this topic Back to topic

Related calculators

Books on Software Development and Project Management Ad

As an Amazon Associate I earn from qualifying purchases.

More Software Development and Project Management questions

  1. For the decision 'A and B' (A and B are conditions whose truth values can be set independently), two test cases were run: (A = true, B = false) and (A = false, B = true). Which statement about coverage criteria is correct?
  2. In bottom-up testing, what is built to stand in for a higher-level module that does not exist yet, so that it calls the lower-level module under test, passes it test data and receives the results?
  3. During testing, a reliability growth curve was plotted with the test time (or the number of test cases executed) on the horizontal axis and the cumulative number of defects found on the vertical axis. The curve is still rising, with no sign of saturating (leveling off). Which judgment is most appropriate?
  4. In the integration testing of firmware with 25 KLOC (25,000 lines), 30 defects were found. Based on the organization's past results, the guideline for defects found in this phase is 2 to 4 per KLOC. Which is the most appropriate evaluation of this result?
  5. In Git, two developers changed the same line of the same file on different branches, and one branch was then merged into the other. Which describes what happens?