ProgrammingAnalysis

TDD is finally dead! Really?

admin3 min read

Back in 2015, I was a big believer in Test-Driven Development (TDD). I followed the "Red-Green-Refactor" cycle religiously: write a failing test, write the minimum code to pass it, then refactor the code; and repeat. I inspired (I hope so) and annoyed countless people with TDD concepts and rituals.

Then my tech lead, Momo, one day, out of nowhere called it a "greedy algorithm."

He was right. A greedy algorithm makes the best local choice at every step to solve a problem. TDD is like that. You solve a problem one "baby step" at a time and bet on the refactoring to lead you to the optimal solution.

As Momo challenged me write a sorting algorithm while scrupulously sticking to the TDD routine, I landed on the InsertionSort, very far from the elegant QuickSort.


So, was TDD useless? No. Momo saw the limit, but missed the point.

The real value of TDD isn't in designing perfect algorithms. It's in the discipline it forces on you:

  • Fearless Refactoring: A full test suite lets you change code confidently.
  • Living Documentation: Tests show how the code should work, better than any manual.
  • Better Design: To test code easily, you have to write decoupled, clear code from the start.
  • Instant Feedback: You know immediately if you broke something. This "fail fast" mindset saves huge debugging time later.

In recent years, when I started using AI tools like (like GitHub Copilot), my first reaction was:

#TDD is finally dead!

I couldn't help thinking of my TDD-evangelist pals who depend on it for their pittance.

Indeed, the strict, mechanical TDD cycle (Red-Green-Refactor) breaks down with AI.

  • AI doesn't do "baby steps." You ask for a function, and it gives you a complete solution with multiple tests all at once.
  • The old rhythm of "think, write a test, write code" is gone. Now it's "prompt, review, refine."

But wait, is it really dead?

Not exactly. The ritual is, but the core idea is more important than ever.

The key lesson of TDD was to define what the code should do before worrying about how to do it. With AI, this is your most critical skill. A vague prompt gives you bad code. A precise prompt that thinks about edge cases and behavior gives you a great starting point.

The New "TDD" Loop for the AI Age:

  1. Think & Specify: Precisely define what you need, including edge cases.
  2. Generate & Review: Ask AI to build it. Critically read the generated tests first, they are now your specification.
  3. Refine the Spec: Ask yourself: "Do these tests match what I need?" If not, refine your prompt and go back to step 1.

Conclusion:

Momo was right. #TDD, as a strict greedy algorithm, kicked the bucket. But the "behavior-first" mindset it teaches is the exact skill you need to guide AI effectively. The tool has changed, but the need for clear thinking hasn't. It's what separates a developer from a prompt typist.

In the same way that a language like Pascal is taught in universities for its perfect illustration of procedural language concepts, TDD should serve as a learning tool - a foundational method for teaching the rigorous, behavior-first discipline that remains essential, even as the technical landscape evolves.

Comments

Leave a comment

Comments are reviewed before they appear.