The Test-Driven Development Workflow
Drive design with the red-green-refactor cycle.
TDD Is a Design Tool
Test-Driven Development is often sold as a testing technique, but its real value is design pressure. By writing the test first you are forced to define an object's public interface, its dependencies, and its contract before you write any implementation. The tests are a byproduct; better design is the product.
Red, Green, Refactor
The cycle has three strict phases:
- Red — write a failing test for the next tiny behavior. It must fail for the right reason.
- Green — write the minimum code to pass, even if ugly.
- Refactor — clean up implementation and tests while staying green.
Discipline matters: never skip Red (you might be testing nothing), never over-build in Green.
All lessons in this course
- The Test-Driven Development Workflow
- Mocking and Stubbing with Mockery
- Integration and Functional Testing
- Mutation Testing with Infection