When AI Writes the Code, the Tests Are Your Contract

On 11 November, Matteo Vaccari of Thoughtworks Italia published an article on martinfowler.com called Tests as Data. It begins with interviews he ran in early 2026 with 26 developers at an organization that leans hard on coding agents. He asked whether they trusted their tests, and the answers were lukewarm. A developer might review the tests when they are first generated, but the agent keeps refactoring code and tests together as features arrive, and after a few rounds nobody can say whether the suite still checks what it was written to check.

In a prototype that’s easy to shrug off. It’s harder to shrug off when the software controls a radio, a spacecraft, or a sensor feed, and a program office has to show what the code was supposed to do.

The numbers behind the distrust

Vaccari backs the interviews with industry reports, and we read each one. The companies behind them sell tooling in this area, so we treat the figures as signals, not measurements.

The Faros AI report draws on telemetry from 22,000 developers across 4,000 teams, and at high AI adoption it shows bugs per pull request up 28.7 percent and bugs per developer up 54 percent. The DX Q1 report covers more than 400 companies. It says nearly 30 percent of merged code is AI-generated and that some teams see a 50 percent rise in defects. CloudBees reports that 81 percent of respondents saw more production incidents from AI-generated code, and that 70 percent now find maintaining the test suite a bigger burden than writing code. Vaccari describes that survey as covering 213 enterprise tech leaders, a figure we didn’t verify.

He says he doesn’t know what causes the decline in quality. He thinks a decline in the quality of functional tests is one plausible cause.

Why agent-written tests drift

Agents produce a large volume of test code, and it’s dull to read. They tend to couple tests to the implementation through heavy use of mocks, so a harmless refactor breaks them. Asked to cover a module, an agent usually writes tests that confirm what the code does today, bugs included, instead of tests that state what it should do.

Put the contract in data

When an agent writes the code, the humans become its customers. That leads Vaccari to make customer tests, written in the language of the problem and run against the system from outside, the main contract between people and agents. He wants that contract in data files, not test code.

For simple cases, the file is a table where each row is one stateless operation with its input and expected output. When the test needs state, it’s a small scenario format giving the starting state, the action, and the state afterward. A short runner reads the files and executes them. Coding agents can write that runner cheaply, and that is what makes the approach practical now. Earlier attempts like Fit and Cucumber needed interpretation layers that were slow to build and fragile to maintain.

One of his examples is an access-control table for an admin dashboard, with columns for role, session state, resource, expected result, and whether the attempt gets logged. Ten rows cover traders, admins, viewers, expired sessions, and a tampered token, and a reader can see at a glance which cases are covered and which are missing.

Here is our own illustration, not from the article, of what rows might look like for a ground-system command check:

modecommandauthenticatedexpected
safeenable transmitteryesrejected
nominalenable transmitteryesaccepted
nominalenable transmitternorejected, logged

Why data files are easier to protect

Agents sometimes weaken or disable tests to claim a task is done. If the contract sits in text files, a team can mark them read-only or add a CI check that fails when a change touches them. Vaccari offers a rule of thumb: a refactor should change production code and nothing else, while new functionality should change production code and test data but leave the runner alone. A diff that breaks that pattern needs a reviewer’s attention.

He adds a second guard from Ivett Ördög’s Constrained Tests pattern. When tests are data files read by a parser, the parser can reject any test that lacks an expected outcome. An agent can no longer pad coverage with tests that run code and assert nothing, so a coverage number starts to mean something.

None of this is sufficient alone. The runner is still code, and an agent can change it. Vaccari recommends mutation testing, where you inject deliberate faults and confirm the tests fail with a clear message. He also recommends checking expected outputs against an independent oracle, such as official documentation or a second implementation. For a COBOL interpreter he built, he required the same customer tests to pass on an IBM i system and on his laptop.

Our reading: defense and space software

This section is interpretation. The article doesn’t mention defense work.

A table of inputs and expected results can be reviewed without reading source. An RF engineer or a ground operator can look at the rows above and say which one is wrong. For a program that has to show a change board what software is supposed to do, that artifact is easier to defend than a passing suite nobody has read.

The same files also help with the problem we described in our post on ground segments, where late integration testing leaves no room to absorb surprises. Vaccari notes that data-driven tests can run through different runners, fast and in-process on a laptop at first, then against a more realistic stand-in later. He also describes having agents build local simulators of external services, and credits the idea to Justin McCarthy, who calls them digital twins. For a radio link or an antenna controller, a simulated version lets the same rows run long before hardware exists.

Limits

Vaccari is open about them. Prototypes don’t need this, since learning fast beats testing early. An external format adds work, and it pays off only if people review at least a sample of the rows. Big steps make it harder for humans to keep a feel for the architecture, and he still recommends exploratory testing by a person.

A starting point

Pick one component whose rules you can state in a sentence, such as a command validator, an allowlist, or a limit check on telemetry. Write twenty rows by hand with someone who knows the domain, have an agent write the runner, and read the runner once yourself. Then add a CI rule that flags any pull request touching the data files, and a second rule that blocks the agent from editing them unless the task calls for it. Run a mutation tool once to see whether the rows catch the faults you’d expect.