TDD Test Driven Development Principle

1. Second-by-Second nano-cycle: The Three Laws of TDD.

Yogesh Wadile
2 min readMar 4, 2020

Three Laws of TDD.

  1. You must write a failing test before you write any production code.
  2. You must not write more of a test than is sufficient to fail or fail to compile.
  3. You must not write more production code than is sufficient to make the currently failing test pass.

2. Minute-by-Minute: micro-cycle: Red-Green-Refactor

If we pull back to the minute by minute scale we see the micro-cycle that experienced TDDers follow. The Red/Green/Refactor cycle.

This cycle is typically executed once for every complete unit test, or once every dozen or so cycles of the three laws. The rules of this cycle are simple.

  1. Create a unit of tests that fails
  2. Write the production code that makes that test pass.
  3. Clean up the mess you just made.

3. Decaminute-by-Decaminute: milli-cycle: Specific/Generic

As the tests get more specific, the code gets more generic.

Programmers make specific cases work by writing code that makes the general case work.

4.Hour-by-Hour: Primary Cycle: Boundaries

The final primary cycle of TDD is the cycle that ensures that all the other cycles are driving us towards a Clean Architecture. Ever hour or so we stop and check to see whether we have crossed, or are encroaching upon, a significant architectural boundary.

Reference https://blog.cleancoder.com/uncle-bob/2014/12/17/TheCyclesOfTDD.html

--

--

Yogesh Wadile

Software Engineer |Distributed | Microservice | Kubernetes | Docker | CI/CD | Mentor