In this article, we will formulate test cases for triangle problems using data flow testing in such a way that all the du and dc paths get covered. The first step is to generate flow graph from the code ( Here’s the code).
Same as path testing make flow graph.
Now, make Decision-to-Decision table in which consecutive nodes are counted as an individual.
On the basis of above table, create DD graph.
After DD graph, it is time to figure out du and dc paths. For this, create ‘ defined node and used at node’ table to view variable’s definition and initialization.
From above table, find du and dc paths.
Based on du and dc paths create test cases, covering each and every variable definition and usage.
Test ID | a | b | c | Expected Output | Program Output | Tested Outcome |
---|---|---|---|---|---|---|
1 | 5 | 10 | 5 | Not a triangle | Invalid Input | Fail |
2 | 10 | 9 | 5 | Scalene triangle | Scalene triangle | Pass |
3 | 5 | 1 | 5 | Isosceles triangle | Isosceles triangle | Pass |
4 | 5 | 5 | 5 | Equilateral Triangle | Equilateral Triangle | Pass |
5 | -1 | 5 | 5 | Invalid Input | Invalid Input | Pass |