A Hardheaded View of TDD
February 15, 2011
I had a chance to pair with Llewellyn Falco last week at Agile Open Northwest. Our approaches to test-driven development are pretty different, so we had some interesting conversations on the nature of TDD. In a followup email, Llewellyn said that his takeaway was that I don't see tests as specifications for my app. To which I responded:
You're absolutely correct that I don't see TDD's tests as specifications. I see TDD and its tests as a tool with three benefits:
- Helping me write correct, usable code now
- Alerting me and others to errors when we change or add code
- Helping us understand the original intent of my code
My approach to TDD is focused on maximizing these three benefits while minimizing the cost of writing and maintaining the tests. Specification isn't part of the picture. (It has value, but it isn't what I use TDD for.)
I may have missed a few of the benefits of TDD in that response, but I think it's essentially correct. I take a hardheaded view of TDD. For me, TDD's tests aren't an end worth pursuing. They're a tool that gives me certain benefits: a check on my work, a suite of regression tests, and code-level documentation. Other than that, they're waste to be minimized.