In this type of testing, test cases are drived by considering all the independent paths of the DD graph.
Here’s is the triangle problem code.
In path testing, first we create the flow graph of the triangle problem based on the program which shows the flow and possible paths.
Once the flow graph is created, with the help of it list all the consecutive nodes and assign an alphabet to them.
After creating DD Table, it’s time to generate DD graph through which Cyclomatic complexity and the possible path will be gathered.
Using DD graph ( Decision to Decision graph ), calculate the cyclomatic complexity which tells all the independent paths.
Cyclomatic complexity = E – N + 2P
= 20-16+2
=6
Possbile paths are:
-A,B,C,D,E,F,G,K,L,M,O,P
-A,B,C,D,E,F,H,I,K,L,M,O,P
-A,B,C,D,E,F,H,J,K,L,M,O,P
-A,B,C,D,K,L,M,O,P
-A,B,C,D,K,L,M,N,O,P
-A,B,K,L,M,O,P
Based on these paths, we will create Test cases.
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 |
6 | 5 | 5 | 11 | Invalid Input | Invalid Input | Pass |
This post was last modified on November 23, 2019