My Struggles with TDD

If you’ve spent any amount of time being a developer, I’m sure you’ve heard of TDD, or Test-Driven Development. The point of TDD is that you write a failing test first, write the code to make the test pass, refactor the code, and then repeat. All programming languages can follow this pattern to create well-constructed code. It also allows you to do more refactoring down the road and make sure that the changes don’t break other aspects of the application.

So What’s the Problem?

I titled this post talking about my ‘struggles’ with TDD. I wouldn’t say I struggle with it because I know how to unit test my code. What I struggle with is using the concepts on a real application. I get the project requirements, I start laying out the database and creating mock-ups. It’s at that stage my developer brain says that I should start writing tests, but I am overwhelmed on where to start.

This leads me to believe my code is less valuable if there’s not some sort of underlying unit tests giving it that coveted 100% coverage. This makes me feel I’m testing more for a number, than to actually make the code more rugged and resilient to bugs.

I’m Not Alone

Recently, there was a big discussion on if TDD is dead or not that I found quite interesting. It was held in a Google Hangout, then posted on Youtube, by a few prominent heads of the programming universe: David Heinemeier Hansson, Martin Fowler, and Kent Beck. It was started by David posing the question, is TDD dead? He listed the reasons why he feels that test-first does not guarantee clean code.

I don’t think David was totally advocating to not do TDD, but moving to doing more system level tests. Those I can grasp because they can more align with how a user would use it. Yes, classes are not in isolation, but at least you can see that the system is functioning correctly.


I wanted to quickly share this dilemma of mine to see if there’s other developers out there that share that same sentiment. TDD is easy to understand how to do it, but doing it on a real project is a whole different story that isn’t as easy to grasp.

Share your thoughts in the comments below or hit me up on Twitter.