For twenty years, test-driven development struggled because teams saw it as too time-consuming. AI has changed that equation.
TL;DR
TDD used to require developers to write the test first and then write the code that made it pass. AI can handle implementation, while the developer still defines what the system should do in a test before the agent starts. Now the agent has a concrete target, and the team has a way to verify the result. That shift changes the economics of TDD.
What This Looks Like
Imagine a team of eight developers. They describe the task to an agent, review the output, decide whether it solves the problem, and merge it. Each person handles five or six tasks in parallel.
This is already happening: the DORA 2025 Report found that 90% of respondents use AI at work. The more interesting question is what happens when code generation gets faster, but the rest of the delivery process doesn’t.
In August 2026, NIST published an initial draft of NIST AI 200-2, which describes the TEVV-Athlon Framework.
The workflow makes the problem easier to see.
The Bottleneck Didn’t Go Away. It Moved.
For twenty years, software delivery followed a predictable path from requirements to code review and production. Until recently, coding was the slowest step. A developer sat down and wrote code. This took days. By comparison, code review was cheap and often took only about half an hour per pull request.
Agents can now cut the coding step from days to minutes, while review still depends on a human reading code at roughly the same speed as in 2015.
Speed up coding without speeding up review, and the queue just moves downstream. Faros AI collected data from over 22,000 developers across more than 4,000 teams over two years. Here’s what that looks like in 2026:
- tasks per developer, +33.7%
- median PR time in review, +441% (vs. +91% a year prior)
- Incidents per PR, +242.7%
- 31% more PRs are merged before any review happens.
The DORA 2025 report makes the same point more cautiously: higher AI adoption is associated with both higher throughput and greater delivery instability.
The bottleneck has moved from writing code to reviewing it.
A Green PR Can Still Be Wrong
A real PR makes the problem clearer.
A developer gave an agent a task: add discount handling for enterprise clients. The agent returned 180 lines. At first glance, the PR looks clean, and every test the agent wrote for it passes.
What’s wrong here?
Those tests verify the behavior implemented by the agent, including any mistakes caused by a misunderstood requirement. If the agent misunderstood the rounding rule, the test will lock in the wrong behavior and keep enforcing it for years.
We’ve seen this in practice. Kent Beck, the creator of TDD, describes the pattern directly: agents tend to write code first, then add tests designed to pass. Beck encountered agents that deleted a failing test instead of fixing the implementation. The 2025 Stack Overflow Developer Survey found that 66 percent of more than 49,000 respondents said AI outputs often need correction.
That pattern describes our PR exactly.
Four Jobs Are Hiding Inside a PR
Break the PR into four jobs, and the key distinction becomes clear.
| Part | What it is | Who can write it |
| Specification | What the system should do | human |
| Test | Automated verification of the specification | human or agent |
| Implementation | Code that passes the test | agent |
| Review | Whether this is actually what is needed | human |
The first and fourth rows describe the same work at different points in the process. That is why TDD matters again.
TDD Wasn’t Wrong. It Was Expensive.
TDD has been around for decades. Kent Beck described the practice as part of Extreme Programming in the early 2000s, and the most rigorous industrial study was conducted back in 2008.
Nagappan and colleagues studied four teams, three at Microsoft and one at IBM, that transitioned to TDD. The result: pre-release defect density dropped by 40-90% compared with similar projects using conventional development workflows. Teams also reported that development took 15 to 35 percent longer at first.
In practice, that meant spending 15-35% more time up front to avoid 40-90% of those defects later. On paper, it was a great deal. In practice, teams often skipped it because the cost was immediate while the payoff was delayed and harder to measure.
The TDFlow authors identify the additional time required as the main barrier to broader TDD adoption.
AI Took the Expensive Half of TDD
That cost structure has changed.
The 15 to 35 percent overhead came from writing both the test and the implementation by hand.
AI can handle much of the implementation, leaving developers responsible for the test.
TDFlow puts numbers on this shift. Researchers at Carnegie Mellon built TDFlow, a workflow of specialized subagents designed to make a given test suite pass. They compared two modes on SWE-Bench Verified (500 real GitHub tasks):
| Mode | Success rate | Cost per task |
| Tests written by humans | 94.3% | $1.01 |
| Tests generated by agent | 68.0% | $4.12 |
Source: TDFlow
SWE-Bench Verified measures performance on 500 human-selected Python tasks judged solvable from the problem description alone. The benchmark asks a much narrower question: whether an agent can produce code that passes a reproducible test. A 94 percent success rate does not mean that 94 percent of your features will be correct. The relevant finding here is that implementation ceases to be the bottleneck once the agent has a real test up front.
The TDD comparison is even clearer in the numbers. With tests written by humans, the success rate rises by 26.3 percentage points while cost falls from $4.12 to $1.01 per task. Human-written tests were both cheaper and more successful.
The extra cost makes sense when the agent burns tokens trying to satisfy a test that was wrong from the start.
The authors also found that TDFlow solves 93.3 percent of tasks when generated tests accurately reproduce the target behavior.
Take the discount example again. Imagine two tests for the same rule. The first says that 50,000 in revenue should produce a 12 percent discount. The second asserts that the function returns a number. Both tests pass with a correct implementation. With a broken implementation, the second can still pass because it never tested the business rule.
Developers know the business context and the rule the code is supposed to enforce.
The hard part isn’t getting the agent to solve a test — it’s giving it one that’s actually worth solving.
AI is getting better at implementation, while humans still define the behavior that matters.
Three Things Changed the Math
Three shifts changed the economics of TDD.
First, implementation got much cheaper. The comparison here shows a drop of more than 90 percent in the price per million tokens between GPT-4 pricing in March 2023 and the 2025 rates. The model inference for work that once took an engineer a full day can now cost only a few dollars.
Second, tests proved to be an effective way to steer an agent. Research by Matthews and Nagappan showed that providing tests alongside a problem description allows the model to solve an additional 12.0% of tasks on MBPP and 8.5% on HumanEval. A test gives the agent an unambiguous specification, unlike a prose description in a ticket.
Third, people in the industry started saying it out loud. In February 2026, Martin Fowler and Thoughtworks hosted a workshop to mark the 25th anniversary of the Agile Manifesto. The report concluded that TDD yields better results with AI agents because it prevents agents from writing tests that validate broken behavior. Kent Beck calls the combination of TDD and agents a superpower.
Where the Agent Will Cheat If You Let It
There are predictable failure modes, too.
The Agent Can Still Cheat
Agents will game the tests whenever they can, making this a systemic behavior rather than a one-off glitch. TDFlow reduces this risk by blocking changes to test directories and restricting access to the filesystem. The Superpowers plugin for Claude Code takes a more aggressive approach: if code was written before a failing test existed, the framework deletes that code.
More Tests Don’t Really Help Here
Tests written by the agent “along the way” are nearly worthless. A February 2026 preprint found that agents wrote tests at similar rates for solved and unsolved SWE-bench Verified tasks, relying heavily on print statements to inspect behavior. The controlled experiment found statistically similar outcomes across prompts that encouraged more or fewer tests. The problem arises when the agent is allowed to decide its own expected behavior; TDD works the other way around by starting from a known requirement.
The Hard Part Is Writing the Right Test
Models still struggle to write tests that reliably capture the target behavior. The TDD-Bench Verified benchmark measures precisely this using a single metric: fail-to-pass (F2P), the fraction of generated tests that fail on old code and pass on fixed code. This is only a baseline requirement: a useful test fails on the old code and passes after the fix. By August 2025, e-Otter++ had reached an average F2P score of 63 percent on the benchmark. That’s a big improvement, but more than a third of the generated tests still miss the target behavior.
Unit Tests Don’t Cover the Whole Flow
A green unit test suite proves only that the tested units satisfy their contracts. Passing unit tests cannot guarantee the end-to-end flow when changes span shared components and routing.
Your First Failing Test Is Already in Azure DevOps
On a legacy codebase, start with the bug reports already sitting in your issue tracker.
A bug ticket with reproducible steps is effectively a failing test that has yet to enter the suite, yet teams write these descriptions every day and discard them after fixing the bug.
The same applies to QA. The test cases already exist, but they usually arrive after the code. Moving them forward by two weeks changes the timing, not the workload.
Larger teams can take this a step further with mutation testing.
Mutation testing checks whether the tests themselves can catch bugs. A common objection to testing is simple: who tests the tests? You can find out in about ten minutes with no special tooling.
Go into the discount rule, swap > for >=, and run the suite. If nothing fails, your tests missed the boundary. The suite is executing the code without protecting the behavior that matters. Try this in a few areas with complex business logic, and you will quickly learn more than a coverage report can show. Coverage counts executed lines. Mutation testing shows whether your tests actually catch bugs.
Next, the same concept scales with tool support. Meta built ACH: it intentionally injects defects into code and generates tests guaranteed to catch them. Engineers accepted 73% of the generated tests.
Meta’s TestGen-LLM applies the same idea at scale by starting with human-written tests and keeping only changes that improve coverage or reliability.
Take One Ticket and Reverse the Order
Try it on one ticket this week by reversing the usual order.
- Have a developer write the failing test before the agent touches the code.
- Make sure the test fails for the right reason.
- Commit the test before implementation, so any attempt to remove it shows up in the diff.
- Only then tell the agent to make the test pass.
- Inspect the diff to confirm that the test files are untouched and every code change stays within scope.
Steps 3 and 5 aren’t bureaucracy. They’re where agents are most likely to go off the rails.
Just as important: don’t use this everywhere. Focus tests on code that will outlive the sprint and require ongoing maintenance. Teams also need to agree on what done means before the agent starts coding. That organizational change is often harder than the technical one.
You may also hear this objection from senior engineers: “So I have to manually do the boring part while the machine gets the interesting part?” The pilot suggests a different tradeoff. In the spec kit pilot, senior engineers spent more time on architecture because writing tests forced them to make clearer decisions about system behavior. Previously, those decisions stayed implicit in the coding process. Now they become artifacts the team can review. That leaves senior engineers more time for the decisions that actually need their judgment.
What I’d Trust Today, and What I’d Test First
The evidence is already strong on a few points.
What is already clear:
- In TDFlow, human-written tests achieved a 94.3 percent success rate at $1.01 per task, compared with 68.0 percent and $4.12 for agent-generated tests.
- The classic 15-35% TDD overhead came from manual implementation. The agent now absorbs that cost.
- Agents will bypass tests when given the opportunity, so technical constraints are the most reliable enforcement mechanism.
- Mutation testing can show whether a test suite actually catches meaningful bugs.
- The bottleneck moved from writing code to checking it. That’s where teams need to focus next.
The economics of TDD have changed.
If you need help building these workflows, our team specializes in AI development services.
Frequently Asked Questions
-
Does AI make TDD worth it again?
Yes. Historically, TDD added 15 to 35 percent to development time up front because developers had to write both the test and the implementation. AI can now handle much of the implementation work, which changes that cost equation.
-
Can AI write meaningful unit tests?
AI can write tests, but agents do much better when a human defines the expected behavior and decides whether the test actually captures it. When the agent invents the test itself, it can just as easily lock in the wrong behavior.
-
How do we adopt TDD on a legacy codebase?
Begin by turning existing bug reports and reproduction steps into failing tests before writing the fix, then focus on code that matters to the business and changes often. Don’t try to retrofit tests onto the entire codebase at once, and use mutation testing to see whether the new tests actually catch bugs.
