In this article, we will perform path testing on the quadratic equation program (Here’s the code) in order to generate test cases.
The first step is to create a flow graph using quadratic equation program.
After creating the flow graph, it’s time to make a Decision-to-Decision Graph (DD Graph). List one by one consecutive nodes and assign an alphabet.
Generate a DD graph.
Now, calculate cyclomatic complexity which represent the number of possible paths,
=E − N + 2P
=16-13+2
=5
After calculating cyclomatic complexity, generate independent paths.
– A,B,D,F,H,I,J,L,M
– A,B,D,F,G,I,J,L,M
– A,B,D,E,I,J,L,M
– A,B,C,I,J,L,M
– A,B,C,I,J,K,L,M
The last step is to formulate test cases based on the calculated independent paths.
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 |