Home Geek Life Is TDD Effective?

Is TDD Effective?

by Geek Insider

Test driven development or TDD has been gaining in popularity over recent years. Many programmers tried it, failed, and came to the conclusion that the technique may not be worth the effort required.

Although some programmers think it’s a good practice, in theory, they say that using TDD requires a lot of time. Others say it’s a complete waste of time.

What is TDD?

TDD is a software development method wherein test cases are used in specifying and validating what a particular code will do. For each functionality, test cases should first be created and tested. New code is only written if a test fails, so that it passes that test on the next run, making it bug-free.

TDD can be summarized with the ‘Red-Green-Refractor’ phrase, which means:

Red – Develop a test case and run to confirm if it fails

Green – To complete the test, implement a code’s logic 

Refractor – Make improvements on the code. This helps avoid duplication so the test can be successfully completed.

With test developed before the actual code logic execution, TDD ensures a high quality product while helping create simple, understandable codes. In even simpler terms:

  1. Write test
  2. Run test
  3. Change or refactor code to correct it
  4. Repeat Step 1

Why Use TDD?

Discussion, papers, and studies have been written about the effectiveness of TDD. And although numbers speak, they don’t exactly explain why TDD should be used in the first place. 

Let’s suppose you’re a web developer that has recently finished an app feature. Would you think that manually interacting with the app via the browser is sufficient in testing this feature? Relying on tests manually done by developers might not be enough. This also means the code for that feature also may not be good enough. TDD ensures that tests are thoroughly run on principles until they are bug-free.

Is TDD Effective?

One experimental TDD study compared projects at IBM and Microsoft with and without the use of TDD. The results indicated that pre-release defect density was lower by 40 to 90 percent on TDD projects, but development time also increased by 15 to 35 percent. 

To apply these numbers in a real-world scenario, let’s suppose a development team works for 100 days to come up with a product that has 100 defects. How much will it improve, if any, if TDD is employed? In a worst-case scenario, completing the project will take 115 days with 60 defects. At best, it will take 135 days with ten defects.

This proves that TDD can be effective, but there will be sacrifices. For example, if the measure of success is dependent on time, TDD won’t be perceived as a great success. But if success is measured by the reduced defect density, then TDD can prove to be very effective.


The main confrontation bdd vs tdd. Another method based on TDD, Behavior Driven Development or BDD, prioritizes business value and requirements of the software instead of code performance and precision. The idea behind BDD is to define how the software behaves in a simple business/user-focused language.

The business-focused perspective of BDD allows for the creation of living documentation that can be maintained and understood easily by team members, which include product owners, developers, and testers.

To simplify the comparison between the two methods, consider TDD as a development practice and BDD as a team methodology. Developers create the tests in TDD, but in BDD, the testers or users create the automated specifications. TDD and BDD can be effectively similar for small developer-centric, co-located teams.

Some of the benefits of BDD include:

  • Real teamwork between developers and business team
  • Functionality priority is justified by the business because it expresses a real value
  • Developers can focus on business-prioritized features
  • Focuses on the needs of the users and the expected behavior rather than the implementation details

Should You Use TDD or BDD?

The answer is both since developer tests are needed for fast feedback and that user tests ensure features are built into user specs. By combining both methods, developers stay focused to get features done cleanly and quickly. It’s essential to understand why and how different computer-aided testing affects the development process in general as well as the product’s final quality.

You may also like

Leave a Comment

Geek Insider