Test What the Product Does, Not How

Tests that describe externally observable behavior survive refactoring; tests that describe internal implementation become a maintenance tax that grows with every change.

What it is

A test that checks how the system achieves an outcome is coupled to the implementation — when the implementation changes, the test breaks even if the behavior is still correct. A test that checks what the system does from the outside is decoupled from the implementation — it only breaks when the behavior changes, which is when it should break. The distinction is not subtle: "assert that this function was called with these arguments" is a how-test; "assert that after calling this API, the database contains this record" is a what-test. What-tests describe the product's observable contract. How-tests describe the product's current internal wiring. Agentic systems fail this discipline most visibly because agents are opaque — their internal reasoning is not inspectable — which tempts developers to test the tools the agent called rather than the outcome the agent produced. Testing which tools an agent called is a how-test. Testing whether the artifact the agent was supposed to produce exists, is correct, and is usable is a what-test. The former breaks whenever tool implementations or selection logic changes; the latter breaks only when the agent stops doing its job.

There is a sharper risk when the tests themselves are agent-generated. A test the agent writes against code the agent wrote can overfit to the implementation it happens to see, or encode the very same misunderstanding that produced the code — in which case the test passes, the code is wrong, and the test certifies the bug. More tests do not fix this; they can multiply the shared blind spot. Each test type carries its own version of the failure, and a finishing system should treat the choice as a tradeoff rather than a default: unit tests can overfit to implementation detail; integration tests are often brittle; end-to-end tests are slow and flaky; mutation tests are costly and noisy; property tests are only as good as the invariants they assert; adversarial tests are easy to under-specify; visual tests need good baselines and tolerances. The agentic opportunity is therefore not merely to write more tests. It is to make test generation, critique, execution, and revision into nodes of the workflow graph — so a separate critic challenges the tests, the suite is actually run against real behavior, and failures feed back into revising both the code and the tests, rather than a single agent grading its own homework.

When to reach for it

When NOT to

Exemplars

Related