# Why AI-generated tests can pass faulty code

> See how an AI can copy the same packing error into code and tests. Break circular testing with independent expectations and a reviewer’s worked example.

Source: https://cueapril.com/knowledge/explanations/how-circular-testing-happens
Updated: 2026-12-02
Index: https://cueapril.com/llms.txt

## Why can AI-generated tests agree with faulty AI-generated code?

Circular testing happens when the expectation comes from the same implementation or assumptions being evaluated. An AI can faithfully reproduce a mistake in both code and tests. Use requirements, independently worked examples and a separate review of the evidence to break that dependency.

## Where does the loop close?

A model reads a function, observes its output and turns that output into an expected value. A second model can reach the same answer if it receives the same function and instructions. Compare the sources of the answers when assessing independence.

## What would expose the mistake?

Give the tester the business rule and reviewed examples. Keep a separate set of cases for evaluation, preserve the first failure and try a deliberate fault against a critical assertion. If the requirement is ambiguous, return the question to its owner before grading the result.

## Worked example: The wrong parcel count becomes the answer

A function reports two parcels for thirteen items even though each parcel holds at most six. A generated test records two because the function returned two. A reviewer who works the packing example from the capacity rule expects three, and can explain the discrepancy without inspecting either model’s answer.

## Try it on your pull request

Choose a change in your repository and tell Cue April what should happen. Review the proposed checks before they run.

[Try Cue April on your repository](https://app.cueapril.com/sign-up/?next=%2Fquality-start)

## Related reading

- [How to choose a test oracle](https://cueapril.com/knowledge/how-to/select-a-test-oracle)

- [Check that the tests can catch a fault](https://cueapril.com/knowledge/playbook/challenge-the-test-results)

- [What a characterisation test can tell you](https://cueapril.com/knowledge/explanations/characterisation-and-correctness)

[Browse the Knowledge base](https://cueapril.com/knowledge)
