liveBook · Manning

Test-driven development

As explained in Effective Behavior-Driven Development

A software development technique in which automated tests are written before implementation code and guide the design of the code.

Test-driven development (TDD) uses automated tests to guide implementation and speed feedback. Write a test before the code; it should fail first. Then write just enough code to pass and refactor before moving to the next test. section 1.2 section 4.1

Figure 1.1 The TDD cycle starts by writing a test and seeing it fail (Red). Then we write just enough code to have the test pass (Green). Finally, we refactor the code to improve its structure

The Red/Green/Refactor cycle shows the sequence from failing test to passing test and code cleanup. section 1.2

TDD is closely related to Behavior-Driven Development (BDD). BDD emphasizes collaboration that keeps requirements, documentation, tests, and the system connected; business-readable tests can help business representatives verify expected behavior. section 1.2

How Effective Behavior-Driven Development covers it

How deep it goes
Explains the Red/Green/Refactor cycle from a failing test through minimal implementation and refactoring.
Examples
Uses a failing automated test, just enough code to pass it, and a refactoring step as the recurring example.
What you can do after
Practice/perform the cycle by writing a failing test, implementing enough to pass, and refactoring before the next test.
How it connects
Links TDD to Behavior-Driven Development and to requirements, documentation, design, and expected behavior.

Also explained in

Compare how 23 books explain test-driven development →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Behavior-Driven Development. The section links point to the parts of the book it draws on.