Sunday, January 10, 2021

Path Testing in Software Testing with Example | Triangle Problem

This post explains Path Testing in software testing. Path testing is one of the test design techniques. Path testing is a structured testing methodology, meaning it is based on mathematics. Path testing is white box testing and complementary to other software testing methodologies like requirements based testing. View my Path Testing tutorial to understand path testing. Then read on.
 
In order to use path testing techniques, you should know about the Control Flow Graph, which represents the program or the algorithm to be tested. Here is the Control Flow Graph for the Triangle Problem example below. In this Control Flow Graph, 1 is the Entry Node and 10 is the Exit node. The nodes 1 through 10 represent the Steps below. The directional arrows e.g. Node 1 to Node 2 represent the control flow between the Steps. The directional arrows are called Edges. Using the Control Flow Graph, you can compute the Cyclomatic Complexity, which is E - N + 2, where E is the number of Edges and N is the number of Nodes. In this Control Flow Graph example, Cyclomatic Complexity is 12 - 10 + 2 = 4.
 
The Triangle Problem is to find out the type of the triangle, given its' three sides. Here is the algorithm for the Triangle Problem.
 
In path testing for triangle problem, there are four basis (independent) paths of algorithm execution, which you need to test with test data.
  • Not a Triangle: Node1 > Node2 > Node3 > Node10
  • Equilateral Triangle: Node1 > Node2 > Node4 > Node5 > Node10
  • Isosceles Triangle: Node1 > Node2 > Node4 > Node6 > Node7 > Node10
  • Scalene Triangle: Node1 > Node2 > Node4 > Node6 > Node8 > Node9 > Node10
Want to learn Path testing with example explained in detail? Want to learn the Path Testing process? Then, please view my Path Testing in Software Testing tutorial. Thank you.

1 comment: