Skip to content
Pocket Grove
Developer blog

Check Whether Your Agent's Tests Supply the Missing Behavior

Published · 6 min read

By · Pocket Grove

Original research brief: . Sources reviewed: .

Quick answer: For each fixture value, ask which production step creates it. If the test inserts the result that the application is supposed to produce, it can pass while that step is missing. Keep useful isolated tests, then add a focused check that begins before the disputed behavior and observes its real output.

A test creates a converted document, opens the preview, and confirms that the pages appear. The preview works. But what evidence establishes that uploading a source document actually produces the converted file?

That question becomes easy to miss when an agent writes both the implementation and its tests. A plausible fixture can carry the same assumption as the code. Another review of the green result may inherit it too.

The useful review target is the boundary between setup and application work. Follow one requirement across that boundary and identify who supplies each piece of state.

Start with a behavior the user can name

Consider an illustrative document service. Its requirement is: when a user uploads a supported file, the service converts it, stores the result, and makes that result available for preview. This example is conceptual; it does not describe a tested implementation.

A narrow preview test might reasonably arrange a stored converted document. It can then check page ordering, empty states, or access control. Those are valuable claims.

The same setup cannot establish that the upload path converts anything. If a broader test also starts with the converted output already in storage, the crucial production step has disappeared from its evidence.

Write the intended claim as a sentence before reviewing the fixture:

Starting with a source upload and no converted output, the application produces a previewable result associated with that upload.

That sentence identifies the initial state, the action, and the observable outcome. It also makes a suspicious fixture easier to spot.

Trace the origin of fixture values

Fixtures are a normal way to create repeatable setup. The pytest fixture guide explains that requested fixtures run and supply their returned values to tests; fixtures can depend on other fixtures. That dependency chain is worth reading when a helper's name hides important preparation.

For the document example, use this worksheet:

Value or resource Who supplies it in production? Suitable test setup?
Source file User upload Yes, as input
User account Account system Yes, when account creation is outside scope
Conversion job Upload handler Observe its creation if that is part of the claim
Converted output Conversion worker Do not pre-create it when checking conversion
Preview record Completion handler Observe it if checking upload-to-preview behavior

The last column depends on scope. Seeding a preview record is appropriate for a preview renderer test. It becomes misleading when the test name or release report claims that document conversion succeeded.

Trace factory helpers recursively. A function named make_upload() might also create the job, mark it complete, and attach an output file. Reading only the visible test body would miss those effects.

Review what the mock replaces

A mock can isolate an unavailable service, return a controlled error, or keep a test deterministic. The question is which responsibility remains inside the application under examination.

Pytest's monkeypatch documentation shows how tests can replace attributes, environment values, and returned objects. These mechanisms make controlled experiments possible. They also make it possible to replace the very function whose behavior the test claims to verify.

In the document example, replacing a paid conversion provider with a fake can be sensible. Keep the application's input selection, request construction, output handling, and persistence active if those are the responsibilities being checked. A fake that inserts the final database row itself moves application work into the test.

Check three things for each replacement:

  • What real boundary does it stand in for?
  • Which input does it inspect before returning a result?
  • Which application responsibilities does it accidentally perform?

A fake that returns success for every request may hide a missing filename or incorrect document identifier. A controlled rejection case can reveal whether the application handles that boundary at all.

Signature checks and outcome checks answer different questions

Python's unittest.mock documentation describes autospeccing, which constrains mock attributes and callable signatures using a real object or specification. That can catch a call with an unsupported argument.

It cannot establish that the supplied argument names the correct document, that the service's real response matches your example, or that a generated output is usable. Those require evidence about meaning and behavior.

Record the narrower claim accurately. “The adapter calls the declared interface” can be supported by a constrained mock. “Users can open converted documents” crosses more boundaries.

This distinction lets the suite stay fast without inflating what a passing result means.

Add the smallest check that can expose the omission

Choose a check that begins before the disputed step and ends after its observable effect. For the conceptual upload flow, begin with no output record, invoke the application entry point, and inspect the stored result through the application's read path.

Use a deterministic local substitute at an expensive external boundary where appropriate. The substitute should return a provider-shaped response; production code should remain responsible for interpreting and storing it. A separate contract check may still be needed for the real provider interface.

Then ask a counterfactual: if the conversion-dispatch step vanished, would this check fail? If the answer is unclear, identify which assertion depends on that step. Merely checking that some output exists may accept stale data from an earlier run.

Associate the observed output with the specific input and ensure the starting state cannot already satisfy the assertion. These are review suggestions, not results from a mutation experiment performed for this article.

Match the evidence to the consequence

A formatting helper may need only focused examples. A feature that writes records or moves user data deserves evidence across the relevant write-and-read boundary. Choose that boundary from the risk of a missed defect.

Independent review helps when it introduces a different observation. Give a reviewer the requirement and the exact candidate revision, then ask which missing implementation could still leave the tests green. A second author who repeats the same fixture assumptions adds less useful evidence.

Keep a short review record:

  1. Name the user-visible behavior and its initial state.
  2. List the fixture values that already exist before execution.
  3. Assign a production owner to each value.
  4. Identify the function or service replaced by every mock.
  5. Select one observable result that depends on the disputed production step.
  6. State what remains outside the check's coverage.

Testing agent instructions asks whether a workflow reliably guides the agent. This review asks whether the resulting application performs its promised work. Both benefit from making the claim explicit before interpreting a green result.

Apps from the studio

All apps

These practices come from shipping Pocket Grove's active apps. If you came here looking for something to install, start with one of these.

Related guides