Chiosa
Software & Code

Generated tests can preserve bugs as expected behavior

On the Risks of using LLM-Generated Tests for Regression Testing · arXiv:2610.11835

3 min
Updated
Empirical study. Stages 1–5 run once per pull request and classify every test T, generated for a specific fault Cfault (RQ1); the table in stage 5 defines the classes (Section 3.1). Only…
Empirical study. Stages 1–5 run once per pull request and classify every test T, generated for a specific fault Cfault (RQ1); the table in stage 5 defines the classes (Section 3.1). Only fault-enforcing pairs (squares) continue: forward propagation (RQ2) carries each through…Figure 3 · On the Risks of using LLM-Generated Tests for Regression Testing · Mohammadali Charoosaei et al. · CC BY 4.0

In plain words

A regression test is meant to catch a bug if it returns. But a test generator that sees buggy code may treat the bug as normal: its test passes while the bug is present and fails after a fix.

The researchers injected artificial faults into code from 145 pull requests in three Python projects, generated tests, and checked them against faulty and fixed versions.

Fault-enforcing tests were more common than tests that caught the injected fault in all three projects, and most tracked fault-enforcing tests kept accepting their fault through the studied history.

The research

A generated test can pass on buggy code and fail when the bug is fixed, making the bug look like intended behavior. Do these tests disappear as a project changes, or can they keep that expectation in place? The answer matters for interpreting what passing generated tests establishes.

The authors inject artificial faults into historical changes, classify generated tests by their behavior on faulty and fixed code, and track fault-accepting tests over time.

The authors injected faults into historical pull requests, generated tests without showing the model the fixed code, and compared each test’s outcomes on faulty and fixed versions. In SciPy, Qiskit and pandas, tests that accepted the fault were more common than tests that exposed it.

They then followed fault-accepting tests through later changes. Most still enforced their fault at the end of the selected histories, supporting the concern that generated tests can preserve faulty expectations as code evolves.

The study uses artificial mutations in three Python projects and one test generator, so its rates do not establish how often real faults or other systems would behave this way.

What the evidence shows

  • When tests preserve bugs

    The paper studies a risk in generated regression tests: when a generator sees faulty code, it may treat the observed behavior as correct. The resulting test can pass while the bug remains and fail after a fix, making faulty behavior look expected. The authors ask whether such tests arise and whether they persist or accumulate as projects change.

  • Testing faulty changes

    To measure that risk, the authors introduced artificial faults into code from historical pull requests in SciPy, Qiskit and pandas. They kept faults that passed the existing project tests and could be detected by another test.

    The language model generated coverage tests from the pre-change code, faulty changed code and their difference, without seeing the fixed reference.

  • What the tests did

    Researchers classified each generated test by running it on faulty code and the fixed reference. A fault-enforcing test passed on the fault but failed on the reference; a fault-revealing test did the reverse.

    Fault-enforcing pairs were more common in each project: 16.9% versus 2.6% in SciPy, 8.4% versus 2.4% in Qiskit, and 16.9% versus 4.8% in pandas. These are shares of classified pairs, and rates varied across pull requests.

  • Faulty expectations persist

    The authors then carried fault-enforcing tests through later pull requests, checking whether they still accepted their original fault. At the end of the selected histories, 82.8%–90.9% of tracked pairs still enforced it.

    Most other pairs could not be judged because the mutated code had been rewritten. Among mutations that remained applicable, nearly all still survived, indicating that the faulty expectation often persisted in these histories.

  • When faults accumulate

    In a separate simulation, the researchers combined faults from later changes and checked both whether project-written tests caught each fault and whether other faults altered a generated test’s behavior. Project tests confirmed catches for a minority of pool members.

    Other faults rarely made a generated test stop accepting its own fault. The simulation is a stress test of this interaction, not a model of real fault accumulation.

Deep

Next paperGenerated tests often fail across valid implementations