Data Flow Testing is a specific strategy of software testing that focuses on data variables and their values. It makes use of the control flow graph. When it comes to categorization Data flow testing will can be considered as a type of white box testing and structural types of testing. It keeps a check at the data receiving points by the variables and its usage points. It is done to cover the path testing and branch testing gap.
The process is conducted to detect the bugs because of the incorrect usage of data variables or data values. For e.g. Initialization of data variables in programming code, etc.
What is Data flow Testing?
Let us understand this with the help of an example.
There are 8 statements in this code. In this code we cannot cover all 8 statements in a single path as if 2 is valid then 4, 5, 6, 7 are not traversed, and if 4 is valid then statement 2 and 3 will not be traversed.
Hence we will consider two paths so that we can cover all the statements.
x= 1
Path – 1, 2, 3, 8
Output = 2
If we consider x = 1, in step 1; x is assigned a value of 1 then we move to step 2 (since, x>0 we will move to statement 3 (a= x+1) and at end, it will go to statement 8 and print x =2.
For the second path, we assign x as 1
Set x= -1
Path = 1, 2, 4, 5, 6, 5, 6, 5, 7, 8
Output = 2
x is set as 1 then it goes to step 1 to assign x as 1 and then moves to step 2 which is false as x is smaller than 0 (x>0 and here x=-1). It will then move to step 3 and then jump to step 4; as 4 is true (x<=0 and their x is less than 0) it will jump on 5 (x<1) which is true and it will move to step 6 (x=x+1) and here x is increased by 1.
So,
x=-1+1
x=0
x become 0 and it goes to step 5(x<1),as it is true it will jump to step
6 (x=x+1)
x=x+1
x= 0+1
x=1
x is now 1 and jump to step 5 (x<1) and now the condition is false and it will jump to step 7 (a=x+1) and set a=2 as x is 1. At the end the value of a is 2. And on step 8 we get the output as 2.
Steps of Data Flow Testing
The life cycle of data in programming code
Types of Data Flow Testing
No actual execution of the code is carried out in Static Data Flow testing. Generally, the definition, usage and kill pattern of the data variables is scrutinized through a control flow graph.
The code is executed to observe the transitional results. Dynamic data flow testing includes:
Advantages of Data Flow Testing
Data Flow Testing Limitations
Data Flow Testing Coverage
Data Flow Testing Strategies
Following are the test selection criteria
1. All-defs: For every variable x and node i in a way that x has a global declaration in node I, pick a comprehensive path including the def-clear path from node i to
2. All c-uses: For every variable x and node i in a way that x has a global declaration in node i, pick a comprehensive path including the def-clear path from node i to all nodes j having a global c-use of x in j.
3. All p-uses: For every variable x and node i in a way that x has a global declaration in node i, pick a comprehensive path including the def-clear path from node i to all edges (j,k) having p-use of x on edge (j,k).
4. All p-uses/Some c-uses: it is similar to all p-uses criterion except when variable x has no global p-use, it reduces to some c-uses criterion as given below
5. Some c-uses: For every variable x and node i in a way that x has a global declaration in node i, pick a comprehensive path including the def-clear path from node i to some nodes j having a global c-use of x in node j.
6. All c-uses/Some p-uses:it is similar to all c-uses criterion except when variable x has no global c-use, it reduces to some p-uses criterion as given below:
7. Some p-uses: For every variable x and node i in a way that x has a global declaration in node i, pick a comprehensive path including def-clear paths from node i to some edges (j,k) having a p-use of x on edge (j,k).
8. All uses:it is a combination of all p-uses criterion and all c-uses criterion.
9. All du-paths:For every variable x and node i in a way that x has a global declaration in node i, pick a comprehensive path including all du-paths from node i
Data Flow Testing Applications
As per studies defects identified by executing 90% “data coverage” is twice as compared to bugs detected by 90% branch coverage.
The process flow testing is found effective, even when it is not supported by automation.
It requires extra record keeping; tracking the variables status. The computers help easy tracking of these variables and hence reducing the testing efforts considerably. Data flow testing tools can also be integrated into compilers.
Conclusion
Data is a very important part of software engineering. The testing performed on data and variables play an important role in software engineering. Hence this is a very important part and should be properly carried out to ensure the best working of your product.