Fundamentals of TDD
Learn the fundamentals of Test-Driven Development (TDD) with clear explanations, best practices, and real-world examples. Start your TDD journey with TDD Buddy.
A collection of references and practices to build and grow your understanding of TDD.
Test-driven development is a short loop: write a failing test that describes the next behavior you want, make it pass with the simplest code that works, then clean up the design while the tests keep you safe. The loop is easy to state and hard to do well. These guides cover the skills underneath it: how to pick the next test, how to get to green without overbuilding, how to tell a good test from a noisy one, and how to name things so the suite reads like a description of the system.
The engine of TDD — Red, Green, Refactor. Understand the core loop that drives test-driven development.
Techniques for making a test pass. Learn the patterns that help you move from red to green efficiently.
How to break down a problem for testing. Identify boundaries and partitions that reveal edge cases.
How to apply the TDD cycle as you code. Shift between low, medium, high, and reverse gears based on context.
What makes a test helpful? Learn the characteristics that separate useful tests from noisy ones.
Naming is hard — understand why and how to improve it. Progress through stages from nonsense to domain language.
Using scenario-style naming to effectively name your tests. Clear names make tests read like documentation.
Where to start
If you are new to TDD, work through the guides in this order:
- The TDD Cycle first. Every other guide assumes you know what red, green, and refactor each ask of you.
- Green Bar Patterns next, so you have a few reliable ways to make a failing test pass: fake it, triangulate, or write the obvious implementation.
- Equivalence Partitions to choose which tests to write. Partitions and boundaries turn “what should I test next?” into a question you can answer on paper.
- Good Test Characteristics, Stages of Naming, and the Test Naming Guide once you have a handful of tests and want them to stay readable.
- TDD Gears when the cycle feels natural and you want to adjust your step size to how confident you are.
Practice alongside the reading
Reading about TDD only gets you so far; the habits come from repetition. Pair each guide with a small kata from the catalog. FizzBuzz Whiz, Leap Year, Prime Factors, and String Calculator are all good first choices because the rules are small enough to hold in your head while you focus on the loop. For a guided first session, follow Your First Kata: FizzBuzz Step by Step.
When the fundamentals feel comfortable, move on to Mastery of TDD for test smells, dependency breaking, and the design side of the practice.