@drpicox
HOMEBLOGTESTINGTEACHING

The Three Rules of TDD

TDD is a discipline that we impose on ourselves to do our job. And like any discipline, we follow a set of rules strictly. If you choose to practice TDD, you should observe three rules.

According to Robert C. Martin these are the three rules of TDD:

  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.

According to Kent Beck in Test Driven Development By Example the shorter version is:

  1. Write new code only if an automated test has failed

  2. Eliminate duplication

These rules triggers one logical conclusion: [TheThreeStagesOfTDD] or the TDD mantra.

Copyright © 2022 David Rodenas
G · T · M π