Basic Path Testing
Definition
Basic Path Testing is a white-box testing technique that checks all possible execution paths in a program to
ensure each path is tested at least once. It is based on the program's Control Flow Graph (CFG).
Steps in Basic Path Testing
1. Draw the Control Flow Graph (CFG).
2. Calculate Cyclomatic Complexity (V(G)).
V(G) = E - N + 2
3. Identify Independent Paths.
4. Design test cases to cover each path.
Example
Program:
1. Start
2. Read A, B
3. If A > B then
4. Print "A is greater"
5. Else
6. Print "B is greater"
7. End
Nodes = 6, Edges = 7
Cyclomatic Complexity: V(G) = 7 - 6 + 2 = 3
Independent Paths:
1. 1 -> 2 -> 3 -> 4 -> 7
2. 1 -> 2 -> 3 -> 6 -> 7
Basic Path Testing
Test Cases:
- A = 10, B = 5 -> A is greater
- A = 3, B = 7 -> B is greater
Advantages
- Covers all possible paths
- Finds logic errors
- Ensures full code coverage
Disadvantages
- Not suitable for very large programs
- Time-consuming
Conclusion
Basic Path Testing is a powerful testing technique that improves software quality by testing all logic paths. It
uses control flow graphs and is best for small to medium programs.
Diagram: Control Flow Graph Example
Yes
Simple CFG for the example program:
Start / Read A, B
End
If A > B
Print A is greater
No
Print B is greater