Data Flow Testing - Revision Questions and
Answers
1. Introduction to Data Flow Testing
Q: What is data flow testing?
A: Data flow testing is a white-box testing technique that focuses on the lifecycle of data
variables—how they are defined, used, and killed within a program.
Q: What is the main objective of data flow testing?
A: To detect improper usage of variables such as using variables before initialization or not using
defined variables.
Q: Define 'variable lifecycle'.
A: The stages a variable goes through: definition (creation), usage (reading/modification), and
destruction (killing).
2. Basic Concepts
Q: What is a definition (def)?
A: A point where a variable is assigned a value.
Q: What is a use?
A: A point where a variable's value is accessed.
Q: Differentiate between c-use and p-use.
A: c-use (computation use): variable used in calculations; p-use (predicate use): variable used in
decision-making conditions.
Q: What is a def-use pair?
A: A pair consisting of a variable definition and its subsequent use without redefinition.
3. Data Flow Anomalies
Q: What is a data flow anomaly?
A: An unusual or suspicious pattern in variable usage.
Q: Explain 'defined but not used' anomaly.
A: A variable is assigned a value but never used afterward.
Q: Explain 'used before defined' anomaly.
A: A variable is used before being assigned any value.
Q: Explain 'defined twice without use'.
A: A variable is assigned a value twice consecutively without being used in between.
4. Coverage Criteria
Q: What is All-Defs coverage?
A: Every definition of a variable must reach at least one use.
Q: What is All-Uses coverage?
A: Every definition of a variable must reach all possible uses.
Q: What is All-DU-Paths coverage?
A: All definition-use paths must be tested.
5. Control Flow Graph (CFG)
Q: What is a CFG?
A: A graphical representation of all paths that might be traversed through a program.
Q: Why is CFG important in data flow testing?
A: It helps identify paths and analyze variable usage across the program.
6. Advanced Questions
Q: How does data flow testing differ from control flow testing?
A: Control flow testing focuses on execution paths, while data flow testing focuses on variable
usage.
Q: What are the limitations of data flow testing?
A: It can be complex for large programs and may not detect all logical errors.
Q: Explain the role of static vs dynamic analysis in data flow testing.
A: Static analysis examines code without execution, while dynamic analysis observes behavior
during execution.
7. Exam-Level Questions
Q: Explain data flow testing with an example.
A: Provide a code snippet and show how variables are defined and used across different paths.
Q: Discuss different coverage criteria in data flow testing.
A: Explain All-Defs, All-Uses, and All-DU-Paths with examples.
Q: Identify anomalies in a given code snippet.
A: Analyze the code and highlight incorrect variable usage patterns.