Data Flow Testing
Overview
Data flow testing is a white box testing technique where the module is tested on the basis that the value of the variable passing is correct. Control flow graphs are used for the same. Flow testing is an excellent approach for integration testing.
What is Data Flow Testing?
Data flow testing is a white box testing type concerned with the flow of variables and not the module's flow. It follows where the variable is referenced. Data flow testing makes use of control flow graphs and associations.
The below example will look at both techniques.
Example
Control Flow Graph of the Above Example
Control flow graphs are used to represent the code graphically. This representation helps depict the code flow of variables to help data flow testing.
Types of Data Flow Testing
1. Static Data Flow Testing
Declaring the variables, using the variables, and finding the values all happen without the code execution is static data flow testing. Control flow graphs are used for the same.
2. Dynamic Data Flow Testing
The variables and their value are examined with the code execution in dynamic data flow testing. The changes in the variable and their references are observed with the requirement that the code must be executed.
Associations
Here associations are made between, where the variable is defined and used. The format of the association is as follows: (line variable declared, line variable used, variable name).
-
int(x)
-
if(x%2==0)
-
x=x+10
-
else
-
x=x+5
Associations of the above code are as follows:
(1,(2,t),x) for the true condition in line 2 (1,(2,f),x) for the false condition in line 2 (1,3,x) for the x being used in line 3 (1,5,x) for the x being used in line 5
There are two types of uses of variables based on how they are being used in the code.
Predicate use: This value decides the flow of the code, as in line 2 is called p-use. Computational use: The variable's value is used by another variable, so if we have z=x in line 6. That would be a c-use.
Advantages of Data Flow Testing
- Data flow testing helps to redefine the flow of code.
- It helps to identify the excess code if it exists.
- It helps to identify computational variables.
- It tests the code without executing it.
Disadvantages of Data Flow Testing
- Since it is white box testing, coding knowledge is required.
- It is a time-consuming testing process.
- It requires a good amount of manual testing.
- It is a slow process as a lot of manual intervention is required.
Data Flow Testing Coverage
- All definition coverage: It covers all the sub-paths from each definition.
- All definition-c use coverage: It covers all the computation use sub-paths from each definition
- All definition-p use coverage: It covers all the predicate use sub-paths from each definition
- All-use coverage: It covers all the c-use and p-use sub-paths from each definition.
- All definition use coverage: It covers all the sub-paths from definition to their respective use.
Data Flow Testing Strategies
Test case selection criteria are as follows
- All-defs: All the sub-paths that include c-use and p-use. Suppose there is a variable x and node i to select all edges.
- All c-uses: There is global node i to all the sub-paths to node j. Select all the sub-paths which are c-use.
- All p-uses: There is global node i to all the sub-paths to node j. Select all the sub-paths which directly use variable x.
- Some c-uses: From the global declaration of variable x with node i, choose selectively sub-paths node j, which affects the module.
- Some p-uses: From the global declaration of variable x with node i. Choose selectively sub-paths node j directly affecting the value of a variable.
Data Flow Testing Applications
- Noticing the change and updation of a variable make the module more bug-free than merely doing branch testing.
- Debuggers are an excellent tool to track data changes in a variable.
- Data flow testing tools are integrable into the compilers helping in unit testing.
Conclusion
- Data flow testing is a white box testing type where the module is tested based on changes recorded by the variable.
- Data flow testing can be done both statically and dynamically.
- Control flow graphs and associations are excellent data flow testing techniques.
- Data flow testing tools are now integrated with the compilers directly.