0Pricing
Testing Mastery: JUnit, Mockito & Integration Tests · Lesson

The Three Laws of TDD

Internalize Robert Martin's three laws of TDD that govern exactly when you may write production and test code.

Discipline Behind the Cycle

The red-green-refactor cycle becomes precise through three short rules known as the Three Laws of TDD, formulated by Robert C. Martin. They constrain exactly when you write code.

The First Law

Law 1: You may not write production code until you have written a failing unit test.

No code is added speculatively. Every line exists to satisfy a test.

All lessons in this course

  1. Introduction to TDD Cycle
  2. Writing Tests First
  3. Refactoring for Testability
  4. The Three Laws of TDD
← Back to Testing Mastery: JUnit, Mockito & Integration Tests