Is TDD Actually Important?
Since I started working, a common thing I have heard from agile coaches, senior developers, or consultants is the importance of practicing test-driven development (TDD). At my previous company, TDD was a far-off land. A utopia that if we just focused and adhered to its principles, we’d receive ease of development, safe refactoring, and engineering bliss to which every other XP practice paled in comparison.
I never got there.
At DICK’s Sporting Goods, the teams on which I’ve worked have practiced TDD religiously. It is no longer some fairyland, make-believe place. It’s our natural state of working. It’s as common as breathing. It’s actually hard for me to write code today without using TDD. So, do I think it’s worth it? Yes!
What is TDD?
There are many, many resources describing TDD. Basically, test driven development boils down to a few rules.
- Do not write any production code until you have a failing test
- Write the minimum amount of production code to get the test to pass
- Keep all tests passing
- Repeat
Another description of this process is called “Red, Green, Refactor”. Create a failing test (red), make it pass (green), clean up the code along the way (refactor).