Automated test generation

Hand-drawn four bold terracotta six-sided outlines of one shape, rotated and scaled, over dense rows of small sand, linen, umber and moss tiles hatched with straight lines.

Automated test generation covers the techniques in which a program, not a person, writes tests or test inputs. Producing inputs is the easier half. A test is only as useful as its test oracle, the procedure that decides whether the behaviour it observes is correct (Barr et al., 2015).

The main families are property-based testing, generators of unit tests (search-based, random and language-model), and metamorphic and differential testing, which compare outputs across related inputs or programs. Generated tests raise coverage more reliably than they expose real faults (Fraser et al., 2015; Shamshiri et al., 2015). They also disagree on how well mutation score, the share of planted faults a test suite catches, predicts its ability to find real ones (Just et al., 2014; Papadakis et al., 2018). Fuzzing, the generation of large numbers of inputs to find failures, has its own article.

The test oracle problem

The oracle decides what a generated test can detect, and oracles range from crash detection to a full specification. A crash is an implicit oracle. Regression testing assumes the previous version of the program can serve as the oracle for behaviour it already had. Where no full specification exists, partial oracles can come from known relationships between outputs, or from information derived from runs or documentation (Barr et al., 2015).

Every kind of oracle has blind spots. A formal model used as an oracle can allow behaviour that cannot occur, or leave out behaviour that matters. A human tester can supply informal expectations and domain norms that no written specification holds (Barr et al., 2015).

A more detailed oracle finds faults sooner but costs more per test. In a comparison of oracles for graphical interfaces, detailed oracles detected faults earlier in testing at a higher cost per test case (Memon et al., 2003). The same authors later found that some faults showed only if the oracle ran during a narrow window of the test (Xie & Memon, 2007). Checking everything is not always needed: in tests generated from state models, checking part of the program’s state revealed nearly as many failures as checking all of it (Li & Offutt, 2017).

Property-based testing

A property-based test states a rule that should hold for every input, then checks it on many generated inputs. QuickCheck, a Haskell library, tests properties written as functions on random inputs and lets the tester define custom input generators (Claessen & Hughes, 2000). An earlier system, DAISTS, already used algebraic properties as both specification and test, but users had to supply the test cases themselves (Braquehais, 2017).

Shrinking turns a large failing input into a small one that still fails. The Hypothesis library for Python does this by simplifying the sequence of random choices the generator made, then generating again from the simpler choices, until it finds a smaller, simpler case that still fails (MacIver & Donaldson, 2020).

Writing generators

Choosing how to generate inputs is a main difficulty practitioners report. Interviewed developers struggled to build input distributions they trusted to exercise a property (Goldstein et al., 2024). In 213 Stack Overflow posts about property-based testing, data generation strategies were the most common challenge (de Oliveira et al., 2026). Tuning a generator for the diversity and validity of its inputs made one set of generators find bugs 3.1 to 7.4 times faster than untuned versions (Tjoa et al., 2025).

How many bugs property tests find Weak evidence: few or small studies support this

Evidence that property tests find more faults than example-based tests comes mainly from artificial faults. In 40 Python test suites, the average property-based test caught about 50 times as many mutants (deliberately altered copies of the code) as the average unit test (Ravi & Coblenz, 2025). Case studies report real bugs found in the NumPy and Astropy scientific libraries through four kinds of properties (Hatfield-Dodds, 2020). A small student experiment comparing QuickCheck with conventional unit tests was too small to give a conclusive answer (Smallbone, 2011).

Language models writing property tests Weak evidence: few or small studies support this

Language models can write valid property tests, but they capture a minority of the properties a library documents. On 40 Python library methods, the best model and prompt needed 2.4 attempts on average to produce a property test that was valid and sound. The best model wrote correct tests for 21% of the properties extractable from the documentation (Vikram et al., 2024).

Results vary widely across models and prompts. On a benchmark of semantic faults injected into Python libraries, eight models were tested. They caught between 42.1% and 83.4% of bugs when prompted to use Hypothesis, and between 31.4% and 76.7% without that guidance. The prompt’s effect ranged from 8 percentage points worse to 42 better (Jing et al., 2026).

Compared with specialist fuzzers, model-written property tests covered more in one system and less in others. Domain-specific fuzzers covered more of the compilers and of PostgreSQL, while the agent covered more of PyTorch (Naziri et al., 2026). On the compilers, the tools found crashes with none in common (Naziri et al., 2026). The agent studied there is told to confirm that a failure reproduces, that callers can pass the failing input, and that the code claims the property it violated (Naziri et al., 2026).

Metamorphic and differential testing

Both techniques compare outputs with each other, not with a known expected output. A metamorphic relation pairs a way of transforming an input with a rule comparing the outputs of the original and transformed tests (Segura et al., 2016). Differential testing runs the same tests on comparable systems and treats any disagreement, hang or crash as a candidate bug (McKeeman, 1998). Its use on compilers is covered in that article.

Relations between outputs have found logic bugs in database systems. A query-partitioning campaign against database systems reported 77 logic bugs (Rigger & Su, 2020).

Generated unit tests

Unit-test generators write tests for a class or module. EvoSuite uses evolutionary search to improve whole test suites against a coverage criterion at once (Fraser & Arcuri, 2011). Feedback-directed random generation builds tests from inputs whose earlier executions it has observed (Pacheco et al., 2007). Pynguin generates coverage-oriented unit tests for Python modules (Lukasczyk et al., 2023).

Do generated tests find real faults Weak evidence: few or small studies support this

Generated tests catch some real faults, but running faulty code is not the same as exposing it. Three Java generators together found 55.7% of the real faults studied, and no single tool found more than 40.6%. For 63.3% of the faults they missed, the generated tests ran the faulty code at least once without exposing it (Shamshiri et al., 2015).

Generated tests did not help people find more bugs in controlled experiments. Giving testers EvoSuite raised the code coverage of their tests, with no measurable improvement in the number of bugs they found (Fraser et al., 2015).

Tests written by language models

Language-model test generators reach high coverage in some settings and trail search-based tools in others. On JavaScript packages, the TestPilot tool’s passing tests reached a median 70.2% statement coverage and 52.8% branch coverage (Schäfer et al., 2024). Yet they covered less than Nessie, a tool built for JavaScript callback APIs, on seven packages (Schäfer et al., 2024; Arteca et al., 2022). In Java, every model studied, GPT-4 included, trailed EvoSuite on coverage (Yang et al., 2024c; Ouédraogo et al., 2026). Up to 86% of generated tests failed to compile in some settings (Ouédraogo et al., 2026).

Coverage and mutation score are unreliable indicators of model-written tests when the code under test is already buggy. On historical Java faults, they were informative in some regression-style comparisons but unreliable when the model generated tests from code that still held the bug (Zhao et al., 2026d).

Generated assertions

Generated assertions tend to check the result the implementation already produces, which limits bug detection. In an experiment across 24 Java repositories, model-generated test oracles mostly reflected what the code already did (Konstantinou et al., 2026a).

Generated oracles can also reject correct code. In the TOGLL evaluation, the false-positive rate was 25% for generated assertions and 7% for checks about which exceptions the code should raise (Hossain & Dwyer, 2025).

Tests generated from requirements Weak evidence: few or small studies support this

Tests generated without seeing the implementation can expose more faults than tests generated after seeing it. In one preprint, tests generated from the task description alone detected 25% of faults. Tests generated after exposure to the faulty code detected 14% (Konstantinou et al., 2026b).

Passing tests generated from requirements can still miss artificial faults that developers’ tests catch. In Req2Test-Bench, agents received the requirement and interfaces with the target implementation hidden. The setup with the most passing tests passed 82.8% of instances and caught every mutant caught by the developer’s test in 33.8% (Qi et al., 2026a).

Ambiguous requirements can leave passing tests with gaps. Among sampled tests that passed but missed mutants, the authors attributed 90–99% per configuration to ambiguous setup instructions or unstated expected results (Qi et al., 2026a).

Checking a change against the previous version

Comparing the old and new versions of a program on the same inputs checks that a change preserved behaviour, with the old version as the oracle (Barr et al., 2015).

Detecting regressions Weak evidence: few or small studies support this

Differential checks expose behaviour changes in model-generated refactors that existing tests miss. In one study across three benchmarks, existing suites missed about 21% of the refactorings whose outputs differed from the original on generated inputs. The analysis covered 3,538 of 4,368 candidates after excluding timeouts and compilation errors (Dristi & Dwyer, 2026).

Version comparison combined with a judgement of the change’s intent has found regressions that developers confirmed. Testora compares the original and modified code and classifies each difference in behaviour as intended or unintended. Developers confirmed 11 of the 13 regressions it reported, at an average 12.3 minutes of analysis per pull request (Pradel, 2026). DiffTestGen, a test generator integrated with Testora, reported regressions that earlier approaches missed; its authors judged five of seven flagged cases to be actual regressions (Hu et al., 2026a).

Changes also break each other. In Coreutils, testing the interactions between changes found five previously unknown errors. Tests that exercised each change in isolation exposed only 57% of the interaction errors (Böhme et al., 2013).

What version comparison misses

Agreement with the old version cannot reveal a defect both versions share. An oracle derived from running the current program records its existing faults as expected behaviour (Mo et al., 2026c). One preprint, PROGRESS, reported detecting 328 of 562 injected Java faults treated as the current version, against none for regression-test generation (Mo et al., 2026c).

False alarms in version comparisons

A mismatch can come from the input or the reference version. On Defects4J, a benchmark of software faults, comparing automated fixes with human-written fixes falsely rejected 6 of 257 correct patches. One patch was rejected because a test input broke a precondition, a condition the program expects its inputs to meet. Optimisations or imperfections in the human-written fixes accounted for three false alarms (Ye et al., 2021b).

Calls to code outside the comparison can also produce false alarms. In a random sample of 30 GPT-4 refactorings flagged by ChangeGuard, manual review confirmed 16 behaviour changes. Changes in calls to external functions explained most of the false alarms (Gröninger et al., 2025).

How reference tests perform at catching fixes that only fit their tests is covered in reward hacking in coding agents.

Validators, schemas and the code that uses them

A value that passes a validator can still break the code that consumes it. The JSON Schema specification states that structural validation alone may not be enough for an application to use certain values correctly (Wright et al., 2022).

Testing the validator and its consumer together can expose the gap. Schemathesis generates requests from an API’s schema and warns when the running API rejects many of them, which suggests the schema does not match its real behaviour (Schemathesis, n.d.). Pact consumer tests run the consumer’s code against an expected provider response and check that it handles it (Pact, n.d.). Comparing two schemas directly found 43 compatibility bugs in API changes and machine-learning pipelines, all confirmed by developers, without needing a concrete data instance (Habib et al., 2021).

Declared types and runtime behaviour drift apart. Of 122 JavaScript libraries with adequate tests, 62 had a library or test that did not conform to its TypeScript declaration. In 22, enforcing the declarations at run time interfered with how the library or its tests behaved (Williams et al., 2017).

One response is to make the check part of a type. The Orthogonal Defect Classification scheme groups failures to validate data before use as checking defects (Chillarege et al., 1992). In a worked Haskell example, a producer that returns a non-empty list states that guarantee in its type. If the producer stops checking for emptiness, its type changes and its consumer fails to type-check (King, 2019).

Measuring how strong a test suite is

A passing test suite may check little. Code coverage records what ran; mutation testing and oracle-gap analysis ask whether the tests would notice if it were wrong.

Mutation score

Mutation testing plants artificial faults in the code and checks whether the tests detect them (Zeller et al., 2024). The mutation score is the percentage of altered versions the suite distinguishes from the original (Just et al., 2014).

Studies disagree on how well the score predicts real fault detection. In one benchmark, detecting mutants correlated more strongly with detecting real faults than statement coverage did (Just et al., 2014). A larger study found all correlations weak once suite size was held constant. Even so, the top-scoring suites of a given size found significantly more real faults than random suites of that size (Papadakis et al., 2018). A later study found mutation most useful for choosing tests after coverage had stopped helping (Chen et al., 2020b).

Among four common criteria, strong mutation testing revealed the most faults in one study (Chekam et al., 2017). Mutation scores in test-driven development experiments and other code quality metrics are covered elsewhere.

Cost limits its use. At Google, mutating a whole codebase creates a large number of mutants, each needing many test executions. Some mutants are unproductive: equivalent to the original, or detectable but not worth a new test (Petrović et al., 2021).

Covered but not checked

Some code that tests run is code they do not check. In eleven Java projects, 18% of the covered branch outcomes they measured could be changed without any test failing (Rahman et al., 2026e). Among three methods for finding such oracle gaps, identifying pseudo-tested statements pointed to the least-checked code, with a median mutation score of 0.32. It was also the fastest (Maton et al., 2025). Assertions matter for this: in ten Java projects, they were significantly correlated with the results of reducing test suites by coverage (Chen et al., 2017).

Tests that check nothing

Some tests pass because they assert nothing. The JNose tool flags JUnit test methods that have a body but no assertion (Virgínio et al., 2021). Generated tests can produce them: the JTExpert generator wrote tests with no assertions when it found no public getters to call (Panichella et al., 2022). A test with no direct assertion may still check results through a helper method (Delplanque et al., 2019).

Tests that never run are a separate risk. The pytest runner reports a run that collected no tests with its own exit code, distinct from success (pytest, n.d.). Tests that coding agents altered to pass are covered in reward hacking in coding agents.

Keeping failing inputs as regression tests

Test tools let a failing input be kept and re-run without generating new ones. Hypothesis recommends an explicit example to make sure an input runs every time (Hypothesis team, n.d.). The libFuzzer tool re-runs a list of saved files without generating new inputs, and its corpus merge keeps only inputs that add coverage (LLVM Project, n.d.b). A practitioner account describes such replay-only regression jobs as generally very short (Pats, 2020). ClusterFuzzLite runs its batch fuzzing on a schedule and prunes its corpus once a day (ClusterFuzzLite, n.d.).

Reproducing race conditions

Race conditions, where the result depends on the order in which threads or processes run, are tested by controlling or recording that order. Chess runs a multithreaded program repeatedly under deterministic schedules, exploring more schedules each time (Burckhardt et al., 2011). The rr tool records a real run in user space and replays it (O'Callahan et al., 2016).

Replaying a run and exploring alternative runs solve different problems. The authors of MODIST, a checker for distributed systems, distinguish replay, which reproduces a bug already seen, from driving the system into untried executions before deployment (Yang et al., 2009). Their checks used several processes serving a bounded number of requests, reusing the systems’ existing tests with minor changes (Yang et al., 2009). An oracle for such runs can be a model: SibylFS decides whether an observed trace of filesystem calls and results is allowed by its model (Ridge et al., 2015). Distributed systems covers testing of networked software more broadly.

Further reading

  • Barr and colleagues, “The oracle problem in software testing: a survey” (Barr et al., 2015): the standard map of oracle types, from crashes to specifications and human judgement.
  • Goldstein and colleagues, “Property-based testing in practice” (Goldstein et al., 2024): interviews on how property tests are written and where generators are hard.
  • Shamshiri and colleagues, “Do automatically generated unit tests find real faults?” (Shamshiri et al., 2015): three Java generators measured on real faults rather than coverage.
  • Papadakis and colleagues, “Are mutation scores correlated with real fault detection?” (Papadakis et al., 2018): the main challenge to mutation score as a predictor.
  • Segura and colleagues, “A survey on metamorphic testing” (Segura et al., 2016): definitions and applications of metamorphic relations.
  • Pradel, “Testora” (Pradel, 2026): comparing program versions and judging differences against the change’s stated intent.

Known gaps

What this article cannot tell you yet.

  1. Whether property-based tests find more production faults than example-based tests at the same writing and running cost was not established: the only matched comparison located was a small, inconclusive student experiment.
  2. How authors choose useful metamorphic relations, and what that costs, was not researched.
  3. Comparative evidence on how well metamorphic and differential testing work across different kinds of software was not researched.
  4. How often language-model-generated tests detect real faults, as opposed to raising coverage or compiling, remains largely unmeasured.
  5. It remains unclear whether giving test writing to a separate agent improves fault detection when access to the implementation and the test generation budget are held constant.
  6. No study comparing test-generation techniques by kind of code change (refactor, validator change, new feature) was located, nor a measured cost of replaying saved failing inputs in continuous integration.
  7. How often file readers and other consumers disagree with the validators in front of them was not measured.
  8. Controlled scheduling and replay were not evaluated on everyday programs that share files between processes.

References

Solid source
Rated highly trustworthy by the research, and every passage taken from it was found in it.
Weak source
Rated low, or a passage taken from it was not found in it.
Medium trust
Rated medium by the research.
Not checked
Rated high, but its passages could not all be checked against it.
Show all 68 references