Test-Driven Development - TDD
Updated 2026-07-30
Summary
Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the software is improved to pass the new tests. This is opposed to software development that allows software to be added that is not proven to meet requirements. TDD is related to the test-first programming concepts of extreme programming, begun in the 1990s. The purpose of TDD is to obtain fast feedback and to build programs using the "illustrate the main line" approach. TDD is a way of thinking with two hats: first, wearing the hat of implementing functionality, with the aid of tests, quickly implement the functionality; then, wearing the hat of refactoring, under the protection of tests, improve code quality by removing redundant code. Tests drive the entire development process: first, they drive the design and implementation of code; then, they drive the redesign and refactoring of code.
Definition
A development process: write a test case first (which will fail), then write just enough code to pass the test, and finally refactor. That is the "red-green-refactor" cycle. Scaffold use: start with the end in mind. It forces us to define "what is success" (test cases) before we start. Not only for writing code, but also for writing plans: "write acceptance criteria first, then plan content" to ensure goal focus.
Introduction
How to use
Start with the end in mind. It forces us to define "what is success" (test cases) before we start. Not only for writing code, but also for writing plans: "write acceptance criteria first, then plan content" to ensure goal focus.
Mechanism
TDD: Write a failing unit test for a feature (red), then write the minimal implementation to make it pass (green), then refactor to remove duplication and bad smells; tests lock behavior and drive design.
Practice
In progress 0/4Practice this model in one real situation:
Cases
- Use unit tests to constrain boundary conditions and prevent regressions; refactor safely under test protection.
Common pitfalls
- Writing too many tests at once makes it hard to get green; treating TDD as a waterfall of "write all tests first"; neglecting refactoring leads to code decay.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E6%B5%8B%E8%AF%95%E9%A9%B1%E5%8A%A8%E5%BC%80%E5%8F%91verified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS