AI Joe
← Blog· Engineering Reality

When Passing Tests Still Ship the Wrong Behavior

November 23, 2026

A test suite built entirely by AI can go fully green while the software violates the actual contract it was supposed to satisfy, because the same model wrote both halves from the same incomplete understanding.

The Details:

  • When one prompt generates an implementation and its tests in a single pass, the tests describe what the code does rather than what a specification requires. There is no human pause, no context switch, no reviewer asking an awkward question. That missing gap used to be where someone caught the mismatch between code and intent; now the two are produced together and agree by construction.

  • The failures that slip through are quiet ones. A retry test might confirm that a function returns the same response twice without ever checking whether a customer got charged twice in the database. A rounding routine can pass every assertion while applying the rule to each line item instead of the invoice total, as the actual finance policy demands. Neither failure throws an error. Both sit behind a wall of green checkmarks until someone reads the original document months later.

  • The fix is to feed the specification into the model before any code exists, and have it extract numbered, testable claims in the specification's own wording. Those claims become the tests the implementation must satisfy, not something the implementation gets to define for itself. Once written, those spec-derived tests must be off limits for casual editing; a failure means either the code or the specification needs a human decision, not a looser assertion.

  • Property-based checks work well here because invariants come from the domain, not from the code's own behavior: a duplicate idempotency key never produces two charges, line items always sum to the invoice total. Ambiguous specifications should be flagged by the assistant rather than silently resolved and locked in with a passing test.

Bottom Line: A green test suite only proves the code agrees with itself; only a specification kept outside the repository proves it agrees with what was promised.

Enjoy this article?

Listen to the Claude Code Conversations radio show or join the community.