How do you check AI-generated tests? Start from the requirement, write independent expected results, and try a plausible defect. A passing test proves only the behavior it actually checks.
A coding assistant changes a function, adds tests and reports that everything passes. The diff looks tidy, but the implementation and the tests may share the same misunderstanding. A passing test shows that the checks succeeded under the conditions exercised. It cannot, by itself, establish that those conditions cover the requirement.
Here is a concrete way to see the difference. In the downloadable Node.js example below, a shipping charge should become zero at an order total of exactly 100. A weak test passes even when the implementation uses > 100. A second test checks exactly 100 and exposes the mistake. Change the comparison to >= 100 and both tests pass. The example demonstrates a test-design problem; it does not measure or rank an AI model.
The steps in this guide help you review assertions, expected values and test results in a coding-agent session or an ordinary pull request. The research linked below describes related failures in a particular benchmark; the small shipping example is a separate reproducible demonstration.
A November 2026 TestMu AI survey reported that 81% of respondents said their teams had merged AI-written code or tests they did not fully understand. The survey was distributed through the company’s community channels and its sample leaned toward quality engineers and testers, so it describes those respondents rather than every development team. The exercise above addresses one narrow question from that broader problem: whether a test would catch a specific wrong comparison.
The September 2026 ExecCritic preprint describes a concrete problem: generated tests can encode incomplete or incorrect behavioral targets, and a shared code-and-test trajectory can create false confidence. Its experiments also show that the quality of test feedback matters; weak generated feedback can hurt repair performance. The study proposes separating test construction from repair and qualifying the tests before using them. That is evidence from a particular benchmark and scaffold, not a measurement of every current assistant.
For your project, the useful question is not whether a model is generally good at tests. Ask whether this test distinguishes the intended behavior from a plausible wrong implementation. That question can be investigated directly. It shifts the review away from polished explanations and toward observable differences. A newer model may improve the initial draft, but the draft still needs an independent behavioral target.
Consider a discount function. The requirement says that orders of exactly one hundred units qualify for a discount. An implementation accidentally uses a strictly greater-than comparison. If the assistant only tests an order of two hundred units, the suite passes while the boundary remains wrong. Adding more examples above the threshold does not address the missing distinction. A test at exactly the threshold does.
Before asking for test code, write the behavior in plain language. Identify the inputs, expected outputs, and any relevant state change. Include the boundary that separates two outcomes. If the requirement is ambiguous, record the ambiguity rather than letting the implementation silently decide. A test can be beautifully written and still enforce the wrong product decision. The person responsible for the requirement must resolve that decision before the assertion becomes authoritative.
An effective instruction is specific: explain which incorrect implementation each proposed test would reject. That does not guarantee good tests, but it makes weak reasoning easier to see. If the answer is only that the test executes a line, it has not yet explained the behavioral protection.
Give expected values an independent origin
An expected value should come from the specification, a trusted reference, or a separately reviewed calculation. It should not be obtained by calling the same implementation that the test is supposed to check. Otherwise the test can become a mirror. The actual result and expected result move together, and a defect changes both without causing a failure.
For a formatting function, use a small explicit example whose correct output a reviewer can inspect. For a calculation, show the arithmetic behind the expected value. For a parser, distinguish valid input, malformed input, and a valid but unusual boundary case. For a migration, specify which records should change and which must remain untouched. These are different kinds of requirements and need different forms of evidence.
There are legitimate uses for reference implementations, snapshots, and property-based checks. The important point is to know what each contributes. A snapshot records an output for later comparison; approving it requires deciding that the captured output is acceptable. A property checks an invariant; it does not necessarily establish the entire result. Neither becomes an independent oracle merely because an assistant generated it in another file.
Break the agreement loop
Prove that the regression test can fail
A regression test is meant to distinguish a broken state from a corrected state. Where the original defect can be reproduced, run the proposed test against the broken version first. Confirm that it fails for the expected reason. Then apply the fix and confirm that it passes. Keep the error output long enough for someone else to understand what was demonstrated.
A failure caused by a missing import is not evidence that the test caught the bug. Neither is a timeout before the relevant action. Inspect the failure location and message. The assertion should reach the behavior you intended to test. If setup fails first, correct the setup and repeat the comparison. Do not turn a broken test harness into a success story simply because the exit code was nonzero.
Sometimes the old environment is unavailable or the defect depends on production data you cannot use. State that limitation. You can still review the assertion, construct a safe synthetic case, or test a deliberately introduced local defect. Keep those checks distinct from reproducing the original incident. Evidence becomes more useful when its limits are visible.
Review test changes separately from code changes
When the same patch modifies both behavior and its checks, review those changes as two questions. First, does the implementation satisfy the requirement? Second, do the tests still enforce the requirement? A corrected implementation may require updated expectations, but an expectation change must have a reason other than making the suite green.
Look for deleted assertions, broader matchers, skipped cases, swallowed exceptions, and mocks that now always return success. None of these is automatically wrong. A test may genuinely be obsolete, or a mock may need to reflect a new contract. The review should explain which requirement changed and why the old check no longer applies. Without that explanation, the test edit is an unresolved part of the patch.
For consequential changes, consider keeping accepted tests outside the repair agent's editing scope. That creates a useful boundary, but it is not a complete defense. Frozen tests may themselves be incomplete or wrong. A separate reviewer still needs to assess their meaning. Separation helps only when the independent review is substantive rather than another automatic approval of the same assumptions.
Treat coverage as a map, not a verdict
Coverage helps locate code that was not exercised. It does not, by itself, tell you whether an exercised path was checked meaningfully. A test may call a function, receive an incorrect result, and only assert that the result exists. The execution contributes coverage while the defect survives. Review the assertion as carefully as the path that reaches it.
A useful sequence is to inspect uncovered branches, identify which correspond to important requirements, and add targeted cases. Then look at covered branches with weak assertions. This second pass often matters as much as the first. Error handling, authorization, serialization, and boundary calculations can all execute successfully while producing the wrong outcome.
Mutation testing can add another perspective by changing the implementation and checking whether tests notice. A surviving mutation deserves investigation, not an automatic conclusion that the suite is bad. Some changes are equivalent under the domain, and some are irrelevant to the requirement. The practical goal is to understand important surviving mistakes. Do not replace one unquestioned dashboard number with another.
Avoid mocking away the actual problem
Mocks make tests faster and more controlled, but they can also erase the behavior under investigation. Imagine a feature that must reject an invalid payment response. If the generated test replaces the entire payment adapter with an object that always returns a successful result, it never reaches the rejection logic. The test may verify that a success message appears while saying nothing about the failure case.
Choose the boundary deliberately. A unit test can substitute the external network while preserving the adapter's response handling. A contract check can validate the shape expected at that boundary. An integration test can exercise cooperating components in a controlled environment. These checks answer different questions. Ask the assistant to name which part is real and which part is simulated before accepting its test description.
Keep fixtures small enough to inspect. An enormous copied response makes it harder to see which field drives the assertion. Use clearly named variations for missing, malformed, delayed, and unsuccessful responses. Avoid putting live credentials or personal data into fixtures. A realistic test does not require copying sensitive production records into the repository.
Diagnose flaky tests before increasing retries
A flaky result is a signal to investigate variability. The cause might be shared state, an uncontrolled clock, nondeterministic ordering, a race, or an external dependency. Repeating the run until it passes does not establish which explanation is correct. It can hide a failure that users still encounter. Save the first useful failure artifact before changing the test.
For a browser interaction, wait for an observable condition rather than assuming a fixed delay is enough. For a background job, verify a completion state rather than sleeping for an arbitrary number of seconds. For time-dependent logic, make the clock controllable where practical. For ordering, assert the order only when it is part of the contract; otherwise compare the relevant contents without inventing a sequencing requirement.
Run the smallest failing case in isolation and then in its normal suite. A test that only fails alongside another test may share state or resources. That observation narrows the investigation, but it is not yet the root cause. Change one condition at a time and retain the evidence that distinguishes your explanation from alternatives.
Ask for evidence that fits the claim
An assistant may report that tests passed after starting a command but before receiving its final result. Require the command, final exit status, and a concise result summary. If a process is still running, the correct state is pending. If the environment prevented execution, the correct state is unverified. A confident paragraph does not replace the missing result.
The same discipline applies to screenshots, coverage reports, and CI links. A screenshot demonstrates a moment in a particular environment, not every interaction. A coverage file may belong to an older run. A CI job can be queued, cancelled, or attached to a different revision. Match the artifact to the exact source being reviewed before treating it as release evidence.
You do not need a huge evidence archive for every small change. Scale the record to the risk. A focused regression case and a completed relevant suite may be enough for a narrow fix. A change to authorization or data persistence deserves broader scrutiny. The goal is a claim someone can verify without reconstructing the entire conversation with the assistant.
A reusable review prompt
Try this instruction when asking an assistant to propose tests: “Read the requirement and identify the behavior that would be wrong. Propose a small set of cases with independently derived expected results. For each case, explain the plausible defect it catches. Do not edit existing expectations merely to match the implementation. Run the relevant checks and distinguish completed results from pending or unavailable checks.”
Treat the response as a proposal. Review its interpretation before authorizing a large test-writing pass. If the assistant identifies a contradiction between the requirement and an existing test, ask it to present the contradiction with evidence. Do not force it to silently choose one side. A clearly reported uncertainty is often more useful than a fast change that embeds the wrong assumption.
After the tests are written, inspect a small sample deeply rather than skimming every test name. Trace the setup, action, and assertion. Ask what would happen if the target function returned a constant, ignored a boundary, or swallowed an error. Those questions expose weak checks quickly. They also help a human reviewer learn which parts of the suite deserve more attention.
Decide when the work is actually complete
A sensible completion record identifies the requirement, the changed behavior, the regression evidence, and remaining uncertainty. It should explain why the test would catch the original mistake and which relevant checks finished. If the patch changes a public contract, it should also identify the callers or documentation affected. Completion is a reasoned assessment of the work, not a count of newly added test files.
Keep the final distinction clear: AI can help produce useful tests, and a passing test can provide real evidence. The problem is treating either as automatically sufficient. Independent expected results, meaningful failure demonstrations, and review of assertion changes make that evidence stronger. They also make disagreements easier to resolve because the conversation is anchored to behavior rather than to confidence.