Skip to content

Review AI-generated tests against the requirement

Review AI-generated tests with worked assertions, a known-defect exercise and a checklist for requirements, boundaries and actual run evidence.

An engineer places a cracked amber gear in a test rig beside a warning lamp and a small AI assistant.
Challenge a test with a known defect and inspect its response. AI-generated conceptual illustration, not a real testing apparatus.

When you review AI-generated tests, start with the requirement beside the test diff. A passing check can confirm that a field exists while leaving the wrong export quantity untouched. Ask which incorrect result would make the check fail.

This guide uses a fictional warehouse dispatch export to compare weak and useful assertions. It gives you a test-review worksheet and a way to challenge a passing result. The example is a teaching model, not a shipped feature or a customer incident.

Review AI-generated tests against an agreed example

Suppose the approved rule says an export contains the quantity still to ship. For an approved line with 10 units ordered and 4 shipped, the file must contain 6. Fully shipped lines must be absent. A lead may export only a warehouse they manage.

Record expected results before reading the implementation. If the agent derives an expected value from the same helper that produces the actual value, both sides can repeat the same mistake. Ask the business owner to settle ambiguous rules, such as how partial cancellations affect the balance.

Google's testing guidance recommends testing public behaviour rather than exposing implementation details. For this export, inspect the downloaded file and its contents. The following example applies that principle to one quantity rule.

Compare what the assertions can detect

These Python excerpts describe a deliberately small model. Its executable source and run record accompany the article's editorial materials. It returns a row; it does not implement authentication, a database or CSV download.

def export_row(ordered, shipped):
    return {"sku": "BRACKET", "outstanding": ordered}

# Weak: accepts the incorrect quantity 10.
row = export_row(10, 4)
assert "outstanding" in row

# Useful: expected value comes from the agreed example.
assert export_row(10, 4) == {
    "sku": "BRACKET", "outstanding": 6
}

The defect is the use of ordered without subtracting shipped units. The weak assertion passes because the field exists. The expected-row assertion fails because 10 differs from 6. Repairing the expression to ordered - shipped makes that assertion pass.

A check that a helper was called may still serve a specific integration contract. It supplies limited evidence about the exported quantity. Keep an outcome check at the existing download seam, and use narrower tests where they help isolate a calculation or failure.

Two test gates compare a wide circular opening with a fitted gear-shaped gauge, beside cracked and intact amber gears.
A more specific check can distinguish results that a shallow check accepts. AI-generated conceptual illustration; the code and table define the exact expected behaviour.

Challenge a passing test with one known defect

In an isolated working copy, temporarily restore a plausible mistake: export ordered quantity instead of outstanding quantity. Run the relevant test unchanged. Confirm it fails at the quantity assertion, then restore the correct implementation and rerun. Keep the defective version out of the product.

We ran this exercise against the teaching model with Python's standard unittest runner. Each cell reports a separate one-test run. These are local example results, not results from a production export.

Model versionColumn-presence testExpected-row test
Defective: returns ordered quantity1 test, OK1 test, FAILED (failures=1)
Corrected: subtracts shipped quantity1 test, OK1 test, OK

The failure demonstrates sensitivity to this particular defect. It establishes nothing about warehouse isolation, empty files or CSV encoding. Inspect why the run failed: an import error or broken fixture would not show that the quantity assertion caught the defect.

Check boundaries the model leaves out

For a real export, map each requirement to an observable assertion through the application's existing seams. Use records that make accidental inclusion or exclusion visible.

RequirementSetupEvidence to inspect
Remaining quantity10 ordered, 4 shippedParse the actual file; assert this line's quantity equals 6.
Exclude completed linesA distinct line with all 5 units shippedAssert that reference is absent, alongside the included line.
Warehouse boundaryA lead assigned to A; a valid B with distinct recordsDirect B request gets the agreed denial response; B's references are absent from the A file.
Empty resultAn authorised warehouse with no eligible linesCheck headings and zero data rows, rather than only a successful status.
Read-only downloadKnown order and stock recordsCheck relevant persisted values remain unchanged after downloading.

These are proposed checks for the fictional specification. Adapt the denial response and output contract to the approved design. An authenticated request test should exercise the permission boundary; a mock that grants access cannot establish it.

Inspect changes that make a suite pass

Read the test diff beside the product diff. If a test previously expected 6 and now expects 10, ask which approved requirement changed. An implementation change alone does not justify changing the expected business result.

  • Reduced assertions: replacing an exact parsed row with a status check loses evidence about file contents.
  • Skipped checks: record the reason, owner and condition for restoring them. A skipped boundary remains unverified.
  • Convenient fixtures: zero shipped units cannot distinguish ordered from outstanding quantity.
  • Excessive mocking: replacing the query or exporter with a prepared answer can bypass the behaviour under review.
  • Narrow runs: confirm the command and filters, including related checks excluded from the run.

If the original test was wrong, record the corrected requirement and evidence. Preserve useful regression cases. Add tests for distinct risks or requirements; a larger count alone supplies no acceptance decision.

Leave a short review record

Use this worksheet with the agent's completion report so a reviewer can find the agreed result and actual run.

Requirement and approved revision:
Representative input / actor:
Expected observable result and its source:
Test file and named case:
Known defect challenged, if appropriate:
Observed failure and reason:
Restored implementation and actual rerun:
Command, revision, environment and output location:
Skipped checks / uncovered boundaries:
Reviewer decision and remaining work:

Our AI agent development workflow keeps implementation and review as separate steps, with a person responsible for acceptance. This worksheet gives that reviewer evidence about test quality. It can accompany a broader AI-assisted delivery review.

For your next change, choose one important acceptance example and identify a plausible defect its test should catch. Inspect the assertion, the failure and the repaired rerun. Record remaining boundaries before making the merge decision.

Working on something like this?

Start with a paid Blueprint, not a guess

One to two weeks to agree the scope, the risks and the measure of success — then a fixed price for the Build.

A note clipped to a notebook sits beside an open laptop and an empty desk chair.
AI workflow Engineering

Resume an AI coding task after a session ends

Resume an AI coding task with a handoff template, read-only Git checks and an example of testing an old completion claim against a new requirement.

4 min read
An engineer studies a blueprint between one robot working on a linked assembly and two robots working at separate benches.
AI workflow Engineering

Single-agent vs multi-agent coding

Choose single-agent vs multi-agent coding with two worked examples and a worksheet for dependencies, ownership and integration checks.

4 min read
A maintainer and small robot use an open map whose paths lead to a reference binder, feature cards and a tool station.
AI workflow Engineering

AGENTS.md: repository context for coding agents

Prepare AGENTS.md with a repository map, verified commands and clear boundaries. Includes a template and checks for stale or conflicting instructions.

7 min read