One failed test case can double your AI validation workload
One failure turns a 59 case plan into 93, and the run you did is spent. The zero failure sample size math behind 59, 93 and 299 test cases for an AI tool.
Sources checked October 26, 2026. Annex 22 is a draft, so nothing below is a requirement. This page covers testing an AI tool. It does not cover using AI to write software tests.
Say you plan 59 test cases for an AI tool, and case 41 fails. Your plan was built to show that the tool fails less than 5% of the time, and one failure breaks that claim. You cannot rerun the case until it passes, and you cannot add cases to rescue the run, because both change the test after you have seen the result. The 59 cases you ran are spent.
A clean rerun costs another 59 cases. If you now allow one failure, the rerun costs 93. Add the spent run and the total is 118 to 152 cases. That is 2.0 to 2.6 times the plan.


No regulation sets a number of test cases for an AI tool, so you work out the number yourself. Guidance asks for a sample size you can justify with statistics and risk. One common way to do that is the zero failure sample size math. You pick the highest failure rate you can accept and how sure you want to be. The math then gives you a count. With no failures allowed, 59 independent cases show, at 95% confidence, that the true failure rate is below 5%. 299 cases show it is below 1%. Allow one failure and the counts rise from 59 to 93 and from 299 to 473, about 60% more cases. Independent means each case is new to the tool, so keep the set apart from anything used to build or tune it.
How many test cases to plan before one fails
Guidance asks for a sample size that is justified with statistics and risk. It does not give a count. FDA’s 2011 process validation guidance was written for manufacturing, and it says the number of samples “should be adequate to provide sufficient statistical confidence of quality”. It adds that the confidence level “can be based on risk analysis”. Draft Annex 22 comes closest for AI. Section 5 says the test dataset, “and any of its subgroups, should be sufficient in size to calculate the test metrics with adequate statistical confidence.” Neither text gives a formula, a count or a method name. Mark Allen Durivage of Quality Systems Compliance wrote in 2017 that FDA regulations, ISO standards and GHTF guidance “do not prescribe the number of runs required for process validation activities.”
The draft also says it “does not apply to Generative AI and Large Language Models (LLM), and such models should not be used in critical GMP applications”, so this article borrows its test data rules by analogy.
So the number has to come from a risk decision you make first. How often can this tool be wrong before it stops being fit for its intended use? The answer depends on what the output feeds. I cover how to make that call in How much validation does your AI need. The zero failure math then turns your answer into a count.
For a large language model (LLM) tool, a test case is one input plus an acceptance rule agreed before testing. The rule says what a pass looks like, such as “the summary names every deviation in the source record and adds none”. Someone who did not build the tool judges each case against that rule.
The zero failure math, in words first
This is one common way teams justify a count. It is industry practice. I found no regulator or standards body that names it, and I am not saying any of them endorses it.
Start with the idea. Suppose the tool really fails 5% of the time. Then each case passes 95% of the time. The chance that 59 cases in a row all pass is 0.95 multiplied by itself 59 times, and that comes to just under 5%. Seeing 59 clean passes would be unlikely if the tool were that bad. So when you do see them, you can say with 95% confidence that the tool fails less than 5% of the time.
A tighter target needs more cases. At a 1% target, each case passes 99% of the time, so a run of passes is weaker proof and you need more of them to rule out luck. The table shows four common targets.
| Target failure rate (%) | Confidence | Cases needed |
|---|---|---|
| 5% | 95% | 59 |
| 1% | 95% | 299 |
| 5%, one failure allowed | 95% | 93 |
| 1%, one failure allowed | 95% | 473 |
To get the count directly, ask how many cases it takes for the chance of all passing to drop to 5%. The answer is the natural log of 0.05 divided by the natural log of 0.95, rounded up to the next whole number. A natural log is the ln button on a calculator. For a 5% failure rate that gives 58.4, so 59. For 1% it is ln(0.05) divided by ln(0.99), which gives 298.1, so 299.
The one failure rows count every way the cases can go with zero failures or exactly one. With 93 cases, the chance of at most one failure at a true rate of 5% is 4.998%. With 92 it is 5.2%, which is just over the limit. So 93 is the smallest set that works.
What one failed test case does to your plan
Suppose you planned 59 cases with zero failures allowed, and one fails. The claim is gone. You cannot rerun the failed case until it passes, and you cannot add cases afterward to reach 93. Both change the test after you have seen the result.


What you can do is stop, investigate and document. Draft Annex 22 section 7 says “Any deviation from the test plan, failure to meet acceptance criteria, or omission to use all test data should be documented, investigated, and fully justified.” The investigation finds out whether the failure points at a real defect, a bad acceptance rule or a bad case. If the fix changes the tool, the full set runs again. I would draw fresh cases for that run, because the team has now seen the ones that failed.
This is where the cost shows up. At a 5% target, the spent run is 59 cases and a clean rerun is 59 more, which makes 118. If the rerun allows one failure, it is 152. At a 1% target the plan is 299 and the total is 598 or 772. Comparing 93 with 59 gives 1.6 times. The discarded run is what takes the real total to between 2.0 and 2.6 times the plan.


If you expect the occasional failure, plan for it up front. Write the one failure plan of 93 cases into the approved test plan before testing starts. Then one failure is inside the plan, and two failures is a failed run.
Keeping the test set independent
The math assumes each case is new to the tool. Draft Annex 22 section 6 asks that test data “is not used during development, training or validation of the model”. It also asks for independent staff. People “who have had access to test data” should not be involved in training and validation of the same model. Small teams can fall back on a “4-eyes principle”.
For LLM tools I add two rules. Nobody who tunes prompts sees the test set, and no case comes from the prompt examples or the retrieval library. Generated cases are a third risk. Draft section 5 says generation of test data or labels “e.g. by means of generative AI, is not recommended and any use hereof should be fully justified.” If a team uses generated cases anyway, I would have a qualified person verify each one and record that. The draft’s status is in AI validation in GxP has no settled playbook.
Subgroups and golden sets
The counts in the table cover one claim about one population. If you claim performance for each subgroup, each subgroup needs its own count. Draft Annex 22 section 3 lets you divide the intended use into subgroups, such as site, equipment or defect type, and the acceptance criteria “may differ for specific subgroups”. Three subgroups at 59 cases each is 177 cases, not 59. Subgroups follow the intended use, which is why I start from the inventory in Start with the inventory: AI use cases and risk tiers.
A golden set is a fixed, versioned set of cases that you rerun after every change to the model, the prompt or the retrieval library. It gives change control a fast answer to “did this change break anything”. Reruns only mean something if the model version is pinned, which is one of the things I look for in what a CSV validator should look for in an LLM gateway. If the tuning team has seen a golden set many times, it is no longer independent. Keep a separate held back set for the formal run.
Writing the count into your validation record
The test plan should state the count, the target failure rate, the confidence level, whether any failure is allowed, and the model and prompt version under test. All of it goes in before testing starts. Draft Annex 22 section 7 asks for an approved test plan with “the pre-defined metrics and acceptance criteria” and a description of how to calculate them. The trace record then links each requirement to its cases and their results. A reviewer can see that the number came from the risk call, and not the other way round.
If you need to defend a test set size to QA, I can help you work through it. Get in touch.
Frequently asked questions
Does Annex 22 say how many test cases you need?
No. Draft Annex 22 section 5 asks for a test set “sufficient in size to calculate the test metrics with adequate statistical confidence”, for the whole set and for each subgroup. It gives no number. You pick the failure rate you can accept and the confidence you want from your risk assessment. The zero failure sample size math is one common way to turn that into a count.
Is 59 test cases enough for an LLM?
Only for one claim: a failure rate below 5% at 95% confidence, with independent cases of equal weight and zero failures. If the tool’s risk calls for a lower failure rate, you need more, such as 299 for 1%. If you claim results for each subgroup, each one needs its own 59. And if one case fails, the claim no longer holds.
Can I use AI to write my test cases?
Draft Annex 22 says generating test data or labels with generative AI “is not recommended and any use hereof should be fully justified”. If you do it anyway, have a qualified person check every generated case and its expected result, and record that check. Keep the generated cases away from anyone who tunes the tool. Real past inputs make better cases.
What is a golden set?
A golden set is a fixed, versioned set of test cases with agreed expected results. You rerun it after every change to the model, the prompt or the retrieval library, so you quickly see whether a change broke anything. Keep a separate held back set for formal validation, because the tuning team will see the golden set often.