skip to content

A quick overview of Test Driven Development

/ 2 min read

Test-Driven Development (TDD) is a software development practice where developers write tests before writing the implementation code. Yes, I know it sounds a little crazy, but keep reading!

What is TDD all about?

The TDD cycle is really simple and it usually consists of three main steps:

  1. Write a failing test: First, you write a test that specifies the desired behavior of the code you are about to write. This test is expected to fail initially, as the code to fulfill this behavior has not been implemented yet.

  2. Make the test pass: Next, you write the minimal amount of code necessary to make the test pass. The focus here is on just enough code to pass the test, not on implementing the entire feature.

  3. Refactor: Finally, once the test passes, you can refactor the code to improve its design and maintainability. The tests give you the confidence to make changes without introducing regressions.

TDD

Does it work?

And now I guess you’re wondering… does this really work? And the answer is clearly yes. Based on a survey carried out by IEEE, Test-Driven Development (TDD) offers numerous advantages, including:

  • Faster time to market: TDD projects were completed, on average, 30% faster.

  • Reduced defects: TDD resulted in code with significantly fewer failures, with bug reduction ranging between 40% and 80%.

  • Enhanced quality: Some projects experienced an impressive 80% improvement in code readability, understandability, and perceived quality.

So you know, next time, why don’t you test this methodology? ;)