# TL;DR

To test everything, we would have to test every possible sequence through the program. Here is why this is not possible. The post is aligned with the Black Box Software Testing Foundations course (BBST) designed by Rebecca Fiedler, Cem Kaner, and James Bach.

Programs do not consist only of branches. Developers need to add loops to satisfy customer expectations. We show how simple addition of a loop to program directed graph significantly increments a number of paths through the program.

# The Example

How many possible paths do we have from start to end?

From Start to End we have three paths:

Start => B => C => F => End

Start => B => D => F => End

Start => B => E => F => End

In all three cases, we were in node F only once. But we have a loop from F to B.

If we go through F two times, that makes 9 paths, 3 x 3. The first time we have three options, and second time three possibilities.

As we can go through loop five times, we have 3 x 3 x 3 x 3 x 3 = 3^5 = 243 paths.

For possible 20 loops, we have 3^20 = 3486784401 paths.

If the starting number of paths is not three but five, with 20 loops, we could not test all those paths. So we sample. We could sample with all paths and loop one. With one path and loops 20 and 21. We could do pairwise testing of paths and the number of loops.

# The Bug

Let’s imagine that in node E, we have a memory leak and that memory is cleaned in node C. Memory leak crashes the program if we hit node E ten times. The number of loops is 20.

If we go through node C before we enter node E ten times, we will miss the bug. But if we go through E ten times before we hit node C, we would get a crash.

Testers are doing tradeoffs daily. Remember that while doing test sampling.