Introduction
When testing software, it is important to check all the different ways the program can run. Path coverage helps find if every possible route through the program's decisions has been tested to catch hidden errors.
Imagine a maze with many forks and turns. To be sure you can find your way out, you try every possible route from start to finish. Some routes may be dead ends, but testing them helps you understand the maze fully.
┌─────────┐
│ Start │
└───┬─────┘
│
┌──▼──┐
│ If │
└─┬───┘
│ ┌─────────┐
┌─▼─┐ │ Else │
│ A │ └──┬──────┘
└─┬─┘ │
│ ┌─▼─┐
┌─▼─┐ │ B │
│ C │ └───┘
└───┘
│
┌──▼──┐
│ End │
└─────┘def test_paths(x): if x > 0: if x < 10: return "Path 1" else: return "Path 2" else: return "Path 3" # Test cases to cover all paths print(test_paths(5)) # Path 1 print(test_paths(15)) # Path 2 print(test_paths(-1)) # Path 3