TDD Cycle
Question
What are the three steps of TDD?
Hint
TDD is test-first development.
Explanation
TDD (Test-Driven Development) follows the Red-Green-Refactor cycle: 1) Red — write a test that fails (the feature does not exist yet). 2) Green — write the minimum code to make the test pass. 3) Refactor — improve the code quality while keeping tests green. Repeat for each feature. Benefits: 1) Tests always exist (100% coverage by design). 2) Better design — testable code is better code. 3) Clear requirements — the test defines the expected behavior. 4) Confidence — refactoring is safe. TDD requires discipline but produces high-quality, well-tested code. Some teams use BDD (Behavior-Driven Development) for higher-level tests.
Related Resources
Related Lessons
- TDD
Learn TDD.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.