Test-Driven Developer (TDD) is way simpler than a lot of people want to make it sound. You basically follow these steps:
- Write a Test: Write a test for the next bit of functionality you want to add.
- Run the Test and See It Fail: This confirms that the test is detecting the absence of the desired functionality.
- Write the Minimal Code to Pass the Test: Implement just enough code to make the test pass.
- Refactor: Improve the code while keeping the tests passing.
- Repeat: Continue with the next functionality.
This cycle is often referred to as Red-Green-Refactor:
- Red: Write a failing test.
- Green: Write code to pass the test.
- Refactor: Improve the code.