Basis Path Testing
Basis Path Testing is a white-box testing technique designed to ensure that all possible independent paths through a program’s control flow are executed at least once. It is based on graph theory and uses the program’s control flow graph (CFG) to identify the basis set of paths—those that provide the minimal number of linearly independent paths required to cover all possible execution paths.
The primary goal of Basis Path Testing is to achieve high code coverage by testing the program’s logic thoroughly, ensuring that all decision points and statements are executed.
Key Concepts in Basis Path Testing
- Control Flow Graph (CFG):
- Represents the program’s logic as a graph with:
- Nodes: Representing statements or blocks of code.
- Edges: Representing the flow of control between statements.
- Represents the program’s logic as a graph with:
- Independent Path:
- A path through the CFG that introduces at least one new edge not previously traversed by other paths.
- Cyclomatic Complexity:
- A metric used to determine the number of independent paths in the program.
- Calculated as: M=E−N+2PM, Where:
- M: Cyclomatic complexity.
- E: Number of edges.
- : Number of nodes.
- : Number of connected components (usually 1 for a single program).
- Basis Set:
- The minimal set of independent paths that ensures coverage of all edges in the CFG.
When to Use Basis Path Testing
- Testing critical or complex logic components.
- Ensuring high code coverage in applications with numerous decision points.
- Verifying newly implemented or modified code for potential errors.





