Introduction to TDD

John Oerter
3 min readFeb 23, 2020

What is TDD?

Whether you’re new to software development or have been around for awhile, you may have heard of TDD, but have never really gotten a full explanation of the process and benefits of adoption. The purpose of this post is to give you a quick introduction to TDD and hopefully pique your interest if you don’t already have TDD in your arsenal of tools.

So what is TDD? To put it simply,

TDD (Test Driven Development) is a methodology of developing software
that relies on very short feedback loops using unit tests.

To practice TDD, start with a failing unit test. Then write only enough code to make that test pass. Finally, refactor the production and unit test code you’ve written. Repeat. This cycle is often called Red Green Refactor cycle.

Uncle Bob Martin summarized this process into what he calls the “Three Rules of TDD”, which are:

  1. You are not allowed to write any production code unless it is to make a failing unit test pass.
  2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
  3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

Why Should I Learn TDD?

Learning and practicing TDD has numerous benefits while developing software.

--

--