ISTQB White-Box Test Design 3 — Questions and Answers
Question 1: A control flow graph has 12 edges, 10 nodes, and 1 connected component. What is its cyclomatic complexity?
- 2
- 3
- 4 (Correct answer)
- 5
Correct answer: 4
Cyclomatic complexity V(G) = E - N + 2P = 12 - 10 + 2(1) = 4, indicating 4 independent paths.
Question 2: Which of the following BEST describes 'basis path testing'?
- Testing every possible execution path through the software
- Testing a set of linearly independent paths derived from the control flow graph (Correct answer)
- Testing only the most frequently executed paths
- Testing paths that include all boundary conditions
Correct answer: Testing a set of linearly independent paths derived from the control flow graph
Basis path testing derives a set of linearly independent paths from the control flow graph, where the count equals the cyclomatic complexity.
Question 3: In white-box testing, what does a 'du-path' represent in data flow analysis?
- A path from a variable definition to its undefinition
- A path from where a variable is defined to where it is used (Correct answer)
- A path that defines two variables simultaneously
- A path through a data store to a user interface
Correct answer: A path from where a variable is defined to where it is used
A du-path (definition-use path) traces the execution path from where a variable is defined (assigned) to where it is subsequently used.
Question 4: A condition `(A || B) && C` is evaluated. How many test cases are required to achieve full condition coverage (each atomic condition true and false at least once)?
- 8
- 4
- 3 (Correct answer)
- 6
Correct answer: 3
Full condition coverage requires each atomic condition (A, B, C) to take both true and false values, which can be achieved with 3 carefully chosen test cases (though 4 is safer in practice, the minimum is 3).
Question 5: What is the PRIMARY weakness of achieving only 100% decision coverage without achieving 100% condition coverage?
- Some statements may not be executed
- Individual conditions within a compound predicate may never be evaluated as false (Correct answer)
- Loop boundaries may not be tested
- Dead code is not detected
Correct answer: Individual conditions within a compound predicate may never be evaluated as false
Decision coverage only requires each branch outcome (true/false) to be executed once, but individual sub-conditions within a compound predicate may never independently evaluate to false.
Question 6: Which ISTQB white-box coverage criterion subsumes statement coverage?
- Path coverage
- Decision coverage
- Both A and B (Correct answer)
- Neither A nor B
Correct answer: Both A and B
Both decision coverage and path coverage subsume statement coverage because exercising all branches or all paths necessarily executes all reachable statements.
Question 7: A tester is analyzing a loop: `for (int i = 0; i < n; i++)`. Which data flow anomaly would be flagged if variable `result` is used inside the loop but never initialized before the loop?
- dd anomaly
- du anomaly
- ur anomaly (Correct answer)
- ku anomaly
Correct answer: ur anomaly
A ur anomaly (use without prior definition) occurs when a variable is referenced (used) before it has been assigned a value.
A control flow graph has 12 edges, 10 nodes, and 1 connected component.
What is its cyclomatic complexity?