One of the principles from a manifesto for agile software development states that – Continuous attention to technical excellence and good design enhances agility.

But how do we focus on technical excellence? Well, for that we need to explore a bunch of good and useful technical practices. One such practice is Test Driven Development or TDD.

In this article, I would walk you through a simple example of creating a Test-Driven code and elaborate a bit about the practice and associated advantages.

What is TDD?

TDD or Test-Driven Development is a common practice for developing code that is simple, maintainable, and well tested. The approach states that one should write “implementation code” only if there is a “failing test case”. It is an iterative approach for developing software products where –

  1. A failing test case is written
  2. Enough business code is created which makes the failing test case pass
  3. Then, if needed, the entire code is refactored.
  4. Finally, the entire process is repeated, creating more tests over a period of time.

Conclusion:

As with any other technical discipline, TDD requires a lot of patience and perseverance to become an expert. Although, once you master it, it becomes a habit that reaps huge benefits. It helps you to create more maintainable, reliable code and also creates a shorter feedback loop if something goes wrong as you build your product. To view the full blog and this blog "What is TDD" is originally published on Agilemania website.