Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M2184

Test-Driven Development - TDD

Test-Driven Development - TDD
TechnicalHigh supportSoftware Engineering
Included
account_tree

Updated 2026-07-30

Loading revision record…

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.

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/4

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%

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.

  • link
    zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E6%B5%8B%E8%AF%95%E9%A9%B1%E5%8A%A8%E5%BC%80%E5%8F%91ZH · Explicit
    verified
account_treeGenealogyexpand_more

RELATED MODELS