Reviewing AI-Suggested Test Coverage Before You Commit It
GitHub Copilot and coding agents can propose a full set of API tests in the time it takes to read the endpoint's documentation. The tests usually run, usually pass, and usually look reasonable. That's exactly what makes them risky to commit without review: a passing test that checks the wrong thing is worse than no test, because it tells everyone the behaviour is covered.
With an assistant in the loop, the bottleneck moves. Writing tests is no longer the slow part; deciding whether they're worth keeping is. I treat that decision as a review gate with a specific checklist, the same way I'd review a colleague's pull request, rather than skimming a wall of green and hitting commit.
In this article I'll walk through the questions I ask of every batch of AI-suggested tests: are the assertions verifying behaviour or just passing, is the coverage duplicated or pointed at the wrong layer, will the tests stay honest as the API changes, and how to make the agent do part of this review for you.
Learn Node.js, Cucumber, GitHub Copilot, APIs, CI/CD, and modern automation by building a complete framework.
Are the assertions verifying behaviour, or just passing?
The most common problem I find in generated API tests is the snapshot assertion. The agent calls the endpoint, sees what comes back and writes assertions that match it. The test passes today and would also have passed if the response were wrong, because it asserts the current output rather than the documented behaviour.
The signs are easy to spot once you look for them:
- Expected values that are oddly specific and appear nowhere in the requirements: an exact timestamp, a generated id, a full error message copied verbatim.
- Assertions only on status code, or only that a field exists, with no check on its value.
- Assertions that can't fail, such as
assert response.json() is not Noneorassert len(items) >= 0. - A mock that replaces the thing being tested, so the test verifies the mock.
For every test I ask one question: where did the expected value come from? If the answer is "the spec, the ticket or the contract", good. If it's "the response at the time the agent ran it", the assertion needs to be rewritten against the real requirement, or the test deleted.
Break the code and see if the test notices
The quickest way to check whether a test protects anything is to break the behaviour it claims to cover and see if it fails. This is the idea behind mutation testing, and you can do a lightweight version by hand on the few tests that matter most:
- Pick the business rule the test claims to verify, for example "orders over the limit return 422".
- Change the code so the rule is wrong: raise the limit, return 200, drop the field.
- Run the test. If it still passes, it isn't testing that rule.
- Revert the change.
Mutation testing tools automate this for unit-level Python code. For API tests running against a deployed service, the manual version on a handful of critical tests is usually enough to reveal whether the generated set has teeth. Line coverage won't tell you this; a test can execute every line of a handler without asserting anything about what it did.
Spot duplicate and misdirected coverage
Agents generate generously. A request for "tests for the users endpoint" can produce fifteen tests where six would do: three variations of the same happy path, two tests for validation the framework already guarantees, and a handful of negative tests that all exercise the same branch.
A useful first step is to see the shape of what was generated without reading every line. pytest --collect-only -q lists test ids, and parametrised cases show up as separate ids. Read that list as a coverage outline: does each test name a distinct behaviour? Then check what's missing, because generated sets tend to be heavy on happy paths and light on the cases that catch bugs: auth boundaries, conflicting state, pagination edges, error bodies.
Also check the layer. Some behaviours belong in a unit test next to the code, not in an API test that needs a running service. An agent writing API tests will test everything through the API because that's what you asked for. I go into this in layering a test suite: unit, API, end-to-end, and into trimming overlap in using AI to spot redundant tests before your suite bloats.
Will the tests stay honest as the API evolves?
A test that's correct today can become dishonest later. The patterns to watch for:
- Brittle exact matches. Asserting a whole response body breaks on every harmless new field, and the usual "fix" is to regenerate the expected body, which snapshots whatever the API now returns, bugs included. Assert the fields that matter, and use a schema check for structure.
- Hard-coded environment data. Ids, emails and tokens that exist only in the environment the agent happened to run against.
- Self-healing by regeneration. When a generated test fails after an API change, the tempting move is to ask the agent to "update the test". Sometimes that's right. Sometimes the test caught a regression, and updating it removes the evidence. Decide which before anyone touches the test.
Make the agent do the first pass
You can move part of this review onto the agent itself, as long as a person still makes the final call. I put the review rules into the repository instructions the agent reads, such as .github/copilot-instructions.md for Copilot:
## Writing API tests
- Every assertion must trace to a requirement. In the PR description, list
each test and the requirement, ticket or contract field it verifies.
- Do not copy values from a live response into expected values.
- Do not modify an existing test's expected values to make it pass.
If behaviour changed, report it.
- Prefer one parametrized test over several near-identical tests.
- Include negative cases: auth, validation, conflict, not found.
The first rule is the useful one. A list of "test → requirement" pairs is far quicker to review than the code, and any test the agent can't justify is a candidate for deletion before you read a line of it. Then I review the diff with the checklist above, spot-check a few critical tests by breaking the code, and commit only what earns its place. For more on what tends to go wrong, see where AI-generated tests get API testing wrong.
Review is the job now
AI-suggested tests are a genuinely useful starting point. The value you add is judgement: which tests check real behaviour, which are noise and which are missing. A short, consistent review gate keeps the suite trustworthy as more of it is generated. If you want to practise this workflow with real API suites, using VS Code and GitHub Copilot with Python or Node, my API testing courses are built around it.