The TDD Cycle: Red-Green-Refactor
When doing TDD, you repeat a short cycle of the following:
-
Write a test (“red”).
-
Get the test to pass (“green”).
-
Optimize the design (“refactor”).
This cycle is often summarized as red-green-refactor, a phrase that stems from unit testing tools used for TDD. Red (fail) and pass (green) derive from SUnit (the first unit testing tool designed to support TDD[8]) and similar GUI tools that use the colors to provide immediate feedback on test results. The text-based output of Google Mock uses red and green when executed in a terminal with color support.
During the refactoring step, you seek to ensure your codebase ...
Get Modern C++ Programming with Test-Driven Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.