Testing & QA
Kent C. Dodds·Jun 29, 2020·6 min readBy Kent C. Dodds 🐨
@kentcdodds
EmbeddingsTestingDebuggingProduct EngineeringRefactoring
AI summary
The article outlines the 'red, green, refactor' cycle of Test-Driven Development (TDD) and identifies specific scenarios where it is most effective. It emphasizes a pragmatic approach, suggesting that TDD provides the most value when fixing bugs or developing complex pure functions, while advising against it during exploratory coding.
Key points
- TDD follows a three-step cycle: writing a failing test (red), implementing minimal code to pass (green), and refactoring for design and readability.
- Using TDD to reproduce bugs ensures the root cause is understood and that the fix is verified by a test case.
- TDD is well-suited for pure utility functions with well-defined inputs and outputs.
- Exploratory coding often benefits from delaying testing and abstraction until the implementation direction is confirmed.
- Testing and type systems are investments that are most effective for code intended for long-term maintenance.