Test Driven Development (TDD) is a powerful tool to produce quality code, but if it is not used correctly it can also put your project in a difficult position if it is not used correctly. In this article, Jakub Nabrdalik explains that TDD is simple to learn, but hard to master. He shares some tips on how to avoid Test Driven Development traps.
He starts by explaining that Test Driven Development and tests are two completely different things and that tests are only a byproduct of TDD. There are three reasons to do TDD:
1. Find the best design
2. Manage the fear of making changes
3. Getting fast feedback after code changes
The five tips he shares to avoid TDD traps are:
1. Verify the right thing
2. Verify only the right thing
3. Verify only one right thing at a time
4. Provide safety and good design
5. Create only unit tests
His conclusion is that “TDD is just a method. It’s a way, not the destination. Whenever you seem to have a problem with TDD, or tests in general, it really helps, to recall what the goal is. Whenever someone gets angry at tests in a project, whenever people try to rediscover the wheel by using integration or functional test only, it’s usually because they used TDD in a very wrong way.”