Software Development and Project Management
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?
- ABranch coverage is achieved, but condition coverage is not
- BBoth branch coverage and condition coverage are achieved
- CCondition coverage is achieved, but branch coverage is not
Show answer and explanation
Answer: C. Condition coverage is achieved, but branch coverage is not
Condition coverage requires each individual condition in a decision (A and B) to take both true and false at least once. In the two test cases, A and B each take true and false once, so condition coverage is achieved. However, 'A and B' is false in both test cases, and the branch for a true decision is never taken, so branch coverage is not achieved. Because condition coverage alone does not guarantee branch coverage, criteria that satisfy both, such as decision/condition coverage, are used. Note that this reasoning uses the values given to each condition; with short-circuit evaluation, as with && in C, where the right side is not evaluated when the left side is false, one may instead count only the conditions actually evaluated.
- A. The decision is false in both test cases, so branch coverage is not achieved.
- B. No test case makes the decision true, so branch coverage is not achieved.
- C. Correct. A and B each take true and false, but the decision 'A and B' is never true.
Continue: 9 more Software Development and Project Management questions