Back to Coding

How Do You Review Generated Tests?

How Do You Review Generated Tests?
AI Tutorials Team 21 April 2026

Ask for tests and you get a suite that passes. That is the difficulty: the tests were written by reading the code, so they encode what the code does rather than what it is supposed to do, and a bug in the implementation becomes a bug in the tests confirming it.

What is the fundamental problem?

Tests derived from an implementation cannot detect that the implementation is wrong. If a function calculates a discount incorrectly, generated tests will assert the incorrect result, and the suite will pass forever while the behaviour stays wrong.

What should you check first?

Whether the assertions match the requirement rather than the code. Read each expected value and ask whether it is what should happen, independently of what the function currently returns.

This is the whole review in one step, and it is the step people skip because the tests pass.

What do generated suites always miss?

  • Empty and null inputs. Frequently absent unless requested.
  • Boundaries. Zero, one, maximum, one over.
  • Failure paths. What happens when a dependency fails.
  • Malformed input. Wrong type, wrong format, unexpected characters.
  • Concurrency. Almost never covered.
  • The awkward real case. Whatever your data actually does.

What does a useless test look like?

One that asserts something trivially true, tests the mock rather than the code, or would pass with the function body deleted. All three appear regularly in generated suites and all three add to a coverage figure.

The quick check is to ask what change to the implementation this test would catch.

What is the coverage illusion?

Percentage of lines executed, treated as a measure of confidence. A suite can execute every line and assert almost nothing, which produces a high number and no protection.

Coverage tells you what was not tested at all. It says nothing about whether what was tested was tested well.

What is the review prompt?

Review these tests against this requirement, not against the implementation. For each test say what change to the code it would catch. List the cases that are not covered, particularly empty input, boundaries and failures. Point out any test that would still pass if the function body were removed.

Is there a better order?

Writing the tests before the implementation, or at least writing the expected values from the requirement before looking at the code. That breaks the circularity, and it is the one change that makes generated tests genuinely useful rather than decorative.

What is generation genuinely good for here?

Volume once the shape is right. Given a correct example test and a list of cases you have chosen, producing thirty variations is mechanical work it does well, and the judgement about which cases matter stays where it belongs.

What about mocks and test doubles?

Where generated suites go wrong most invisibly. A test that mocks the thing it is meant to be testing passes reliably and verifies nothing, and it is a common pattern in generated code because mocking removes the awkward setup.

The check is what the test would catch if the real implementation changed. Where the answer is nothing, the mock has replaced the subject rather than its dependencies. Over-mocking also makes a suite brittle in the other direction, since tests break when internal details change even though behaviour did not, which trains people to update tests reflexively rather than to read them.

What is the standard to hold?

A test suite is worth having when it fails on a wrong change. Run it against a deliberately broken version of the function; if everything still passes, the suite is a coverage report rather than a test.