Extreme AI Programming · Chapter 10

Testing, Without Drudgery

Every testing discipline, from TDD and BDD to property-based and mutation testing, has faced the same economics: thorough suites take time to write and more to maintain, so teams test the critical paths and leave edge cases to chance.

We have yet to fully digest the end of that compromise. AI agents display an extraordinary, almost embarrassing, aptitude for test creation. They effortlessly produce tests for newly authored code, legacy systems long left untouched out of fear, and the dreary spectrum of edge cases and error handling that human developers typically bypass. With an agent handling the labour, the incremental cost of adding another test drops to virtually zero. Consequently, the historic tension that has compelled engineering leaders to accept "tests that merely pass review" over "tests that genuinely validate functionality" has dissolved.

There is a catch: none of this is permission to stop thinking.

Five thousand green tests that prove nothing

Ask an agent to "write tests for this code", and it will reliably hand you back a large number of passing tests, pushing your coverage figures up. I see it happen constantly in our own work. But much of the time, the agent has just produced tautologies dressed up as verification. A test that asserts a getter returns what the setter set is not a test; it is the code restated in a second syntax. A test that mocks every dependency and then checks that the function called those mocks proves only that mocks behave like mocks. A test that simply asserts the code does whatever it currently happens to do is just a snapshot pinned up as an assertion. It will break the moment anyone refactors, yet stay silent when something is genuinely wrong. Tests like these catch nothing. They inflate the coverage figure and give the team a false sense of security.

Behaviour, not method

Effective tests are a different animal. An effective test describes what the system is supposed to do, not how it currently does it. It fails only when the system produces the wrong result, so it survives an implementation rewrite because it never knew how the implementation worked. In a real sense, the suite is the software specification, written in a form a machine can run.

A trap hides in that sentence. If the agent writes the tests by reading the code, the suite isn't a specification of anything. It mirrors whatever the code already happens to do, a snapshot tautology from a moment ago, now produced at scale and wearing a coverage badge. For a test to mean anything, the agent must know what the software is supposed to do before it writes a line, and it cannot recover that intent from the implementation. It has to arrive from somewhere else: the decisions the team actually made, the outcome they agreed on, written down and handed to the test-writing agent as its input. This is the argument that articulation surfaces somewhere else. A suite is only ever as good as the specification it was written against, and a specification is only worth anything once every perspective on the team has signed up to it.

Getting an agent to produce the valuable kind rather than the numerous kind comes down almost entirely to telling it, in advance, what valuable looks like. Do not test methods; test behaviour. Write tests that would still be correct if you threw away the implementation and rebuilt it. Don't mock what you don't need to; use real collaborators wherever you can, because integration is where most production bugs live. Test the boundaries: zero and one, the maximum, the wrong type, concurrent access, and partial failure. Test the error paths as carefully as the happy ones, because the error paths are where systems hurt people. Hand those instructions to a senior engineer, and they nod and call them obvious. Hand them to an agent, with care, and they are the difference between a suite that wastes everyone's time and one genuinely worth having.

Testing the tester

Because the agent now writes the tests rather than the engineer, a question opens up that barely existed before: did it write the right ones? A green suite tells you the code does what the tests say. It does not tell you the tests say what the specification meant. So now there are two loops to close, not one. The inner loop checks the code against the tests, and the agent can run that all day without help. The outer loop checks the tests against the specification, and that is where the human judgment lives. An agent that has quietly misread the spec will write a thorough, green, confident suite that verifies the wrong thing, and nothing inside the inner loop will ever tell you.

Behaviour-level tests are the verify step of the loop made executable. The double loop reminds us that the verifier is now an agent too, and we check an agent's work; we don't trust it.

What the developer does now

A more subtle, yet profoundly interesting, evolution is taking place. Engineers no longer manually write assertions. Instead, their role has shifted from code generation to critical evaluation: defining what requires verification, assessing whether the test suite adequately addresses meaningful risks, and intervening when tests are flawed or critical vulnerabilities are overlooked. The primary responsibility has transitioned from crafting test implementations to evaluating what merits testing, moving from pure output to high-level discernment.

Thoroughly auditing test suites is a distinct discipline many software engineers have yet to master, largely because, for three decades, the person writing a test was also the one trusting it. That era has ended. The refined intuition that lets an experienced reviewer examine a green test suite and recognise that a key edge case remains unaddressed is human judgment built over a career, a quality no code coverage metric can replicate.

For the business, the implication is blunt and underappreciated. The confidence floor under every release rises. Tests get dense where they were always thin. The old trade-off, where teams shipped with less coverage than they wanted because more cost more than they had, stops applying, because the thing that made coverage expensive was the typing, and the typing is gone.

Agents don't get bored, and they don't leave the error paths for a calmer week that never arrives. So stop wrestling with it. Hand the mechanics to the agent and keep the judgment for yourself. After decades of losing this fight, I didn't expect to be the one writing that the compromise is over. It is.