Data flow testing doesn’t deal with the flow of the program, instead, it tracks which variable is used when. It means that it simply checks the initialization and usability of variables.
In this, we will drive test cases using Data flow testing approach by considering the Quadratic equation example. The first step is to create a flow graph from the code of the Quadratic Equation.
Using the flow graph, create a Decision to Decision Graph ( DD Graph) by converting each set of consecutive nodes into a single node.
Replace these numbers with correspondent DD nodes.
Create a Defined and Used node table to get a clear view of variable usage.
On the basis of the above table, we will generate du and dc path respectively.
All the ‘Y’ in the above table are DC path and ‘Path nodes’ are DU paths.
Now, create the test cases from input provided by the user in such a way that all the paths get covered.
Test ID | a | b | c | Expected Output | Program Output | Tested Outcome |
---|---|---|---|---|---|---|
1 | 0 | 5 | 5 | Not Quadratic | Not Quadratic | Pass |
2 | 1 | 5 | 5 | Real | Real | Pass |
3 | 9 | 5 | 5 | Imaginary | Imaginary | Pass |
4 | 5 | 10 | 5 | Equal | Equal | Pass |
5 | -1 | 5 | 5 | Invalid Input | Invalid Input | Pass |