03 — Why testing cannot be complete

More paths than seconds.

+ The questionWhy can't a team simply test every case before release?

Thirty decisions, a billion paths

A routine with 30 independent yes-or-no decisions has 1,073,741,824 distinct paths through it, because each decision doubles the number of paths that came before. A device program has thousands of decisions, many of them inside loops that can run any number of times, and each path can be taken with different data values and at different moments relative to other events. The number of distinct behaviors is therefore not just large. It is too large to count.

Suppose a program had only 100 independent decisions and a test rig could run a billion paths a second. Running every path once would take about 40 trillion years, nearly 3,000 times the age of the universe. Faster computers do not change the conclusion, because each extra decision doubles the work. The FDA's software validation guidance states the consequence without arithmetic: "Except for the simplest of programs, software cannot be exhaustively tested," and "path coverage is generally not achievable."

05 — Each decision doubles the paths
1 decision: 2 paths 2: 4 3: 8 4: 16 16 paths schematic 30 decisions → 1,073,741,824 paths 100 decisions → about 1.3 × 10³⁰ paths at 1,000,000,000 tests a second → about 40 trillion years age of the universe about 13.8 billion years nearly 3,000 times the age of the universe each path can also run with different data and timing
CodeReadoutFocal detail
Plate 05 — Every independent decision doubles the number of paths through a program. With 100 decisions, testing each path once at a billion tests a second would take about 40 trillion years, so complete testing is impossible for any real device.

Presence, not absence

The computer scientist Edsger Dijkstra drew the conclusion that shaped software engineering. In his 1972 Turing Award lecture he said that program testing "can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence." A test that passes shows that one path, with one set of values, gave the expected answer. It says nothing directly about the paths not taken.

Dijkstra's limit does not make testing useless. It makes testing a sample, and like any sample its value depends on how it was drawn. A test campaign chosen at random from the space of possible inputs would almost never reach the rare combinations that matter, such as the four simultaneous conditions of the HAMILTON-C6 recall in Chapter 2. A campaign chosen from what the software is required to do, and from the ways it could cause harm, reaches far more of them. The FDA's guidance states that testing alone "cannot fully verify that software is complete and correct." Part II therefore describes the rest of the evidence that a software lifecycle produces.

Coverage counts the lines that ran

A coverage tool reports which statements of the code a test campaign executed, or which branches, the alternative outcomes of each decision. A campaign can execute every statement and still miss a wrong condition, because executing a line with one value does not test it with others. The FDA's guidance calls statement coverage "insufficient to provide confidence" on its own, and even full branch coverage leaves most paths unexercised.

How many failure-free runs prove a rate?

Statistics gives a precise answer to a narrower question: if a program runs many times without failing, how high could its failure rate still be? The rule of three answers it. When no failures are seen in a number of independent trials, the one-sided 95 percent upper confidence bound for the failure probability is about three divided by that number. That bound is the highest failure probability at which that many trials would still all succeed at least 5 percent of the time.

Solved example: the cost of a zero

A team runs a function 300 times under realistic conditions and sees no failure. By the rule of three, the true failure probability could still be as high as 3 in 300, or 1 percent, at 95 percent confidence. To bring the bound down to 1 in 1,000, the team needs about 3,000 failure-free runs; to 1 in 1,000,000, about 3,000,000. A target used for life-critical aviation software is 1 failure in 1,000,000,000 hours. To show that rate, the team would need about 3,000,000,000 failure-free hours of realistic operation, which is about 342,000 years. NASA researchers Ricky Butler and George Finelli made the same point in 1993. Their target was 1 failure in 1,000,000,000 ten-hour missions, or 1 in 10,000,000,000 per hour, and they asked how long a test must run to expect even one failure at that rate: about 1.1 million years on one system, and 114 years even with 10,000 copies tested in parallel.

The bound holds only when the test runs resemble real use, so that the rare inputs of the field appear in the test as often as they do in practice. That condition is a second weakness of statistical testing for safety, after the number of runs it needs: by their nature, the inputs that cause harm are the ones nobody thought to make common in the test.

06 — What a run of zeros can prove
100 1,000 10,000 1,000,000 10⁹ 10¹⁰ 1 in 10 1 in 100 1 in 1,000 1 in 10⁶ 1 in 10⁹ 1 in 10¹⁰ UPPER 95% BOUND ON FAILURE RATE (LOG SCALE) FAILURE-FREE TRIALS OR HOURS (LOG SCALE) 300 runs → 1 in 100 3,000 → 1 in 1,000 3,000,000 → 1 in 1,000,000 3 × 10⁹ hours → 1 in 10⁹ per hour about 342,000 years of operation unreachable by testing alone Butler & Finelli 1993: about 1.1 million years for 1 in 10⁹ per 10-hour mission (1 in 10¹⁰ per hour) rule of three: with zero failures in n independent realistic trials, the 95% upper bound is about 3/n
ReadoutFocal detail
Plate 06 — With no failures in n realistic trials, the failure rate is below about 3 in n at 95 percent confidence. That is useful for modest claims and useless for the rates life-critical software needs, which would take hundreds of thousands of years to show.

Choosing the inputs that matter

If testing cannot be complete, the question becomes which inputs to try. Three ideas guide most of that choice. Inputs can be grouped into classes the software should treat alike, with tests at the boundaries between classes, where off-by-one mistakes occur. Combinations of settings can be covered systematically rather than exhaustively. And the hazard analysis of Chapter 4 can name the specific sequences that would cause the most harm, such as the ventilator's four conditions, so that each becomes a deliberate test.

The second idea has unusually direct evidence from medical devices. NIST researchers Dolores Wallace and Richard Kuhn studied FDA recall reports from 1983 to 1997 and found 109 that described their failures in enough detail to show what triggered them. In all but 3 of those 109, testing every pair of parameter settings would have revealed the failure. That is 97 percent of them; the authors give 98 percent. The other 3 needed more than two conditions to occur together. The number of tests needed to cover all pairs of settings grows slowly as settings are added, so pairwise testing is affordable where testing all combinations is not.

The HAMILTON-C6 recall shows the limit of pairwise testing. Its failure needed four conditions, so a pairwise campaign would not have been sure to find it, and only an analysis of what happens when a sensor fails during suctioning would have pointed to that sequence. Testing, then, is necessary and never sufficient. The confidence a regulator accepts comes from testing chosen by requirements and risk, applied at several levels, repeated after every change, and backed by a process that makes faults less likely to be written in the first place. That process is the subject of the next part.

Write the test strategy from the hazards, not from the code

For each hazard the software could contribute to, list the inputs and sequences that could lead to it, including combinations of user actions, sensor states and timing. Make those deliberate tests; cover the remaining settings with boundary values and all-pairs combinations; and record which hazards rely on testing alone and which also rely on safeguards built into the design, so that a reviewer can see where the testing argument is weak.

+ What this chapter established
  • Paths through software multiply with every decision, so even modest programs have far more behaviors than any campaign can test.
  • Testing can show that faults exist but cannot show their absence; coverage measures what ran, not whether it was right.
  • By the rule of three, proving a very low failure rate by failure-free testing would take an impossible amount of realistic operation.
  • Useful testing is a deliberate sample: input classes and boundaries, all pairs of settings, and sequences named by the hazard analysis.
Created with Claude (Anthropic).
Educational reference material, not engineering, regulatory or clinical advice. Product and company names referenced are the property of their respective owners.