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?

  1. Do not write any production code until you have a failing test
  2. Write the minimum amount of production code to get the test to pass
  3. Keep all tests passing
  4. 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).

Test driven development seems easy on the surface. It’s just a few steps, but it really requires a shift in the way we think about writing software. Instead of jumping straight to a solution in the code, we are forced to think about the simplest things the code should do and build up from there.

We consider edge cases and what we expect the code should do in cases of exceptions. It requires us to know those “gotchas” up-front, since our test cases are only as good as the known requirements.

Positives of Practicing TDD

Code Coverage



Negatives of Practicing TDD

“We need to go fast!”

“This is weird.”

“Not everything needs tested.”

If something is important enough to have production code associated with it, it’s important enough to have a test. Yes, this even includes REST controllers and repositories. You guys are testing your controllers and repositories…right?

“We have QA. They’ll find any bugs we missed during development.”


Our test code becomes just as important as our production code. Our tests should live, grow, and be maintained just like our production code. This means our tests should also be DRY, readable, and maintainable.

As engineers, we’re the ones who have to support the software we write. We’re the ones who get called in the middle of the night for a critical production issue. Wouldn’t it be better if that bug could have been avoided all together? The answer is yes!

Becoming disciplined in TDD will truly make your life easier as a software engineer. It will lead to safer code changes, greater confidence during deployments, and fewer interruptions to your sleep schedule.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store