Is TDD dead in 2021?
That’s the question that skeptical people often ask about the TDD approach. Some people claim it is not necessary anymore.
Others still use it and teach others about TDD.
I have used TDD on various projects. Based on my experience, it can help you in your projects. And it will improve your code quality.
Some people claim it is hard to do TDD. If you are new to this approach, it might be a bit more difficult in the beginning. Another issue that comes up often when talking about TDD is that some developers don’t know how to test code correctly.
TDD is a great tool to enhance your software development process if applied correctly and in the proper context.
This blog post provides more details about TDD and its current health.
TDD – Origins
Test-driven development is an agile software development process in which developers write tests before writing code. The goal is to ensure the code is of high quality and is fully functional. You use a test-first approach to achieve clean code.
TDD as a practice begun at the end of the 1990s. Kent Beck published in 1999 the book Extreme Programming Explained, where he introduced the idea of “test-first development.”
The TDD became a real thing in 2003, when the same guy, our Kent, published another book, Test Driven Development: By Example.
After that, many developers and companies have used TDD to develop and release their applications successfully.
TDD has many benefits, which are now well-known. It allows developers to think about the problem in small steps by focusing on one failing test case at a time. You then write only enough code to make that particular test pass. It also enables you to refactor and thus reduce the technical debt of your software application. This way, TDD helps you avoid any unnecessary complexity or design decisions during coding. With TDD, you write simple code first that just passes the failing tests.
TDD is not only about testing at work. TDD can be used in other situations as well! For example, TDD has also been successfully applied to students of all ages learning programming languages. It has become a popular technique for teaching object-oriented design.
When did TDD die?
Fast forward to 2014.
In his article, David Heinemeier Hansson (DHH), the founder of Ruby on Rails and co-founder of Basecamp, stated that TDD is dead. His main objection to using TDD is that it hurts the design of the application. For example, writing unit tests forces you to create many small objects that complicate the design. Also, there are too many abstractions. In other words, there was test induced design damage.
Shortly after writing the article, Kent Beck, Martin Fowler, and DHH had a series of hangout calls. DHH continued to state that TDD never really worked for him. Kent Beck and Martin Fowler were more diplomatic and more realistic. Kent noted that he sometimes used TDD, sometimes didn’t. But he was ok with mixing different styles as long as you adjust the process to your needs.
Well said, Kent, well said.
TDD – is it really dead?
Many companies are wondering about the validity of TDD and whether they should adopt it. TDD has been around since the 1990s and has been proven to be a good tool for many organizations. However, one common misconception is that TDD is strictly for new projects or startups.
TDD has shown that it is an important tool for developers and companies at all stages of development. This is because it focuses on getting feedback early and often to make sure the production code is good and works properly.
TDD is not dead in 2021. It will never be dead because there will always be projects where developers can use TDD effectively.
Today and in the future, developers will want to make sure their code is not broken and works properly. By writing tests first, developers can see if they are on the right track or not. They can implement the functionality, run the whole test suite, and check whether the functionality works properly. Test failures tell to the developer that he introduced a bug and should go back and fix the issue.
When you work on an established and more mature project, TDD can help as well. For example, you can use it when bugs are found in production – this is called “defect-driven testing.” The process of defect-driven testing tells that when you find a bug in your application, fix it and add a test for the bug. The test eliminates every chance of the same bug occurring again.
When to use TDD
TDD is not always the best approach to software development. But if you are developing an already well-understood application or very stable, TDD is a perfect choice. Moreover, it is more recommended than manually test all the user stories all the time.
TDD also works well when you need to implement a feature that contains an algorithm. You can write tests to check if the code is doing what it is supposed to do. And evolve your algorithm as you add more tests.
However, having TDD in place doesn’t mean you don’t need a QA team. In the case where you have high code coverage due to TDD, it replaces a lot of manual testing. QA can spend more time on exploratory testing and writing automated UI tests with Selenium.
When not to use TDD
When startups are iterating on their product, TDD might not be the best approach in that phase. Instead, it is more important to get feedback as your product grows and becomes more stable. The early stages of a startup’s development are about figuring out what the market wants.
You use can TDD, but there is a high chance that you will have to re-implement different parts of your application often. With that, you will also need to take care of unit tests. Some of them you will need to remove, and some of them you will need to rewrite. And that’s not the optimal use of your time.
The other part of application development where TDD should not be used is when you need to develop a database layer or rich user interface. It will take much longer to deliver the same results by using TDD.
Is TDD dead?
Many people nowadays are saying that TDD is dead because not all developers follow this process. The problem with this logic is that there are still many people who use TDD daily. Therefore, as long as TDD continues to live among the software development community, it is not dead.
TDD is still a practical approach when developing software. Companies should not be scared of trying out this process by themselves because it has been shown that TDD works very well for different projects. In addition, when using TDD, companies can deliver higher quality software with fewer bugs.
It will never be dead because there will always be new projects where TDD can shine. Therefore TDD will live as long as the software industry continues to grow and develop.