Skip to content
Figure 1Test levels against test types: AI testing adds evaluation and property checks to the usual grid
Test levels against test types: AI testing adds evaluation and property checks to the usual gridFunctionalPerformanceSecurityUsabilityRegressionUnityesyesIntegrationyesyesyesSystemyesyesyesyesAcceptanceyesyes
The usual levels still apply. AI testing adds two kinds of check to the grid: behaviour measured as rates on an evaluation set, and properties that must hold for any output.

How to test AI systems: oracles, evaluation sets and risk

A conventional test compares an output with an expected value. An AI component rarely has one: the same input can yield several acceptable answers, the answer can change between runs, and correctness is a rate rather than a yes or no. The discipline of testing still applies. What changes is the oracle, the pass criterion and the amount of data you need before a result means anything.

Quick answer

Test an AI system in three layers: the conventional software around the model with ordinary tests; the model's behaviour against a held-out evaluation set with a statistical pass criterion, such as a false positive rate below a stated ceiling with a confidence interval; and properties that must hold whatever the output, checked with metamorphic tests. Then monitor in production.

Key figures

Test layers
3: software, model behaviour, properties
Pass criterion
a rate with a confidence interval
Minimum slice size
about 300 cases per slice
Standard
ISO/IEC TR 29119-11
Syllabus
ISTQB AI Testing
Re-run trigger
any model, prompt or data change

Why the oracle problem is the whole problem

Testing research calls the difficulty of deciding whether an output is correct the oracle problem, and Barr, Harman, McMinn, Shahbaz and Yoo's survey treats it as one of the oldest open questions in the field. For most business software the oracle is cheap: the specification says a discount of 10 percent on 200 is 20. For an AI component the oracle is expensive or absent. A summariser can produce many good summaries of the same text; a classifier is expected to be wrong some of the time; a ranking has no single right order. That does not make the component untestable. It moves the tester's work from writing expected values to designing measurements.

The practical consequence is that a single test case proves very little. One correct answer from a text classifier tells you nothing about its error rate, in the same way that one fast response tells you nothing about the p95 latency in a performance test. The unit of evidence becomes a sample: a few hundred cases per slice of the input space, scored against a criterion that is written down before the run.

Three layers of testing

The three layers; most teams test only the first and the headline number of the second
LayerWhat is testedOracleTypical technique
Software around the modelInput validation, output parsing, timeouts, fallbacks, logging, access controlExact: the specificationUnit, integration and security testing as for any service
Model behaviourAccuracy, false positive and false negative rates, calibration, behaviour on each input sliceStatistical: a labelled evaluation setHeld-out evaluation with confidence intervals, confusion matrices
PropertiesInvariance, directional expectations, consistency, safety constraintsRelational: how outputs of related inputs must relateMetamorphic testing, invariance tests, adversarial slices

The first layer is where most production incidents actually come from, and it needs nothing new. A model that returns malformed output, a timeout that is not handled, a retry loop that doubles cost: these are ordinary defects found with ordinary black-box and white-box techniques. Treat the model as an unreliable external dependency and test the code that calls it the way you would test code calling any flaky service.

Model behaviour: rates, not verdicts

The second layer measures how often the model is right, and on which inputs. The artefact is an evaluation set: labelled cases the model has never seen, stratified by the slices that matter to the risk (language, length, domain, user group). The result is a confusion matrix and its derived rates, each reported with a confidence interval so that a reader can tell a real difference from noise. Designing that set well is a craft of its own, covered in the guide to evaluation test set design.

Write the pass criterion as a rate with a bound, before the run: for example, the false positive rate on human-written text must be below 1 percent, with the upper end of the 95 percent confidence interval below 2 percent, on every language slice with at least 300 cases. A criterion written after the results are in tends to be written around them.

Properties: metamorphic and invariance tests

Metamorphic testing, introduced by Chen, Cheung and Yiu in 1998 and surveyed by Segura and colleagues in 2016, sidesteps the oracle by checking relations between outputs instead of the outputs themselves. You may not know the correct sentiment score for a review, but you know it should not change when a person's name in the review changes, and it should fall when a positive word is replaced by a negative one. Ribeiro and colleagues' CheckList method organises these into three kinds of test: minimum functionality tests (simple cases the model must get right), invariance tests (changes that must not move the output) and directional expectation tests (changes that must move it one way).

  1. Name the property

    State what must hold whatever the exact output: a classifier's verdict does not depend on the author's name; a summary never introduces a figure absent from the source; a detector's verdict does not flip when line breaks change.

  2. Write the transformation

    Define the input change that exercises the property: swap names from a list, reformat whitespace, translate and back-translate, truncate to 80 percent.

  3. Generate pairs at volume

    Apply the transformation to a few hundred seed cases so that the failure rate, not a single example, is the result.

  4. Set the tolerance

    Decide how often a violation is acceptable. Zero for safety properties; a small stated rate for soft ones.

  5. Keep them as regression tests

    Every property test goes into the suite that runs on each model, prompt or data change.

Risk tiers decide the depth

Not every AI feature needs the same rigour. Risk-based testing applies unchanged: score likelihood and impact per feature and let the score set the depth. The NIST AI Risk Management Framework and the EU AI Act both organise obligations by the harm a system can cause, and a tester can borrow the same logic. A feature that suggests a subject line needs a sample check and property tests. A feature that flags a person, a document or a transaction as suspicious needs a full evaluation per slice, a documented false positive ceiling, a human review path and monitoring, because its errors land on people.

Test lead's rule

If an AI output can be used against a person, the false positive rate is a release criterion, measured per subgroup, with its confidence interval printed next to it.

Monitoring is part of the test plan

A model evaluated in September meets a different population in March. Inputs drift, users adapt, and a component that sits behind a prompt changes whenever the prompt does. Plan for it in the test plan: sample live traffic for periodic human labelling, track the flag rate and the disagreement rate between the model and reviewers, and re-run the full evaluation on any change to the model, the prompt or the preprocessing. The guide to testing LLM features covers the regression suite that makes those re-runs cheap.

Common questions

Can an AI system be tested at all if its output changes between runs?

Yes. Treat each output as a sample from a distribution and test the distribution: run each case several times, measure the rate of acceptable outputs, and test properties that must hold on every run. Fix the random seed or temperature where the system allows it for reproducible regression runs.

What is the oracle problem?

The difficulty of deciding whether a given output is correct. It is mild for most business logic and severe for AI components, which is why AI testing leans on labelled evaluation sets, relational (metamorphic) checks and human review instead of exact expected values.

How many test cases does an AI evaluation need?

Enough that the confidence interval around each rate you care about is narrower than the difference you need to detect. As a working minimum, about 300 cases per slice lets you bound a rate near zero below about 1 percent; rates in the middle of the range need more to be precise.

Which standards cover testing AI systems?

ISO/IEC TR 29119-11 gives guidelines for testing AI-based systems within the 29119 series, the ISTQB AI Testing syllabus covers the same ground for certification, and the NIST AI Risk Management Framework sets out how to govern and measure AI risk. The EU AI Act adds legal testing and documentation duties for high-risk systems.

Is accuracy a good pass criterion?

Rarely on its own. Accuracy hides which errors are made and on whom. State the false positive and false negative rates separately, per slice, each with a confidence interval, and choose the one whose errors cost more as the release criterion.

Sources

  1. Barr, Harman, McMinn, Shahbaz and Yoo, The Oracle Problem in Software Testing: A Survey, IEEE TSE (2015)
  2. ISO/IEC TR 29119-11:2020, Guidelines on the testing of AI-based systems
  3. NIST AI Risk Management Framework (AI RMF 1.0)
  4. Ribeiro et al., Beyond Accuracy: Behavioral Testing of NLP Models with CheckList (2020)

Further reading named in the text

  • ISTQB, Certified Tester AI Testing (CT-AI) syllabus, version 1.0 (2021)
  • Tsong Yueh Chen, S. C. Cheung and S. M. Yiu, Metamorphic Testing: A New Approach for Generating Next Test Cases (Hong Kong University of Science and Technology, technical report, 1998)
  • Sergio Segura, Gordon Fraser, Ana B. Sanchez and Antonio Ruiz-Cortes, A Survey on Metamorphic Testing (IEEE Transactions on Software Engineering 42(9), 2016)
  • Regulation (EU) 2024/1689 laying down harmonised rules on artificial intelligence (the AI Act)

This guide is part of the testing AI systems hub. It is best read alongside how to benchmark an ai text detector and evaluation test set design for ai models, which cover the neighbouring questions.