TDD part 2
Its long overdue, but I wanted to share what I learned about the Red, Green, Refactor process of Test Driven Development, and why it makes sense.
The fist step is to write a failing test. This will be before you have written any code in your program/website/whatever. So since you have no code, of course your first test will be failing.
Then, write the minimum amount of code to get the test passing (green). Once you accomplish that, its time to refactor. You can either refactor the code (to make it more efficient, better, cleaner), or you can refactor your tests (make them more comprehensive, add new one), but don’t refactor your code and your test at the same time.
Once you’re factored, you should have have another failing (red) test, so you can start the process over.
Thats red, green, refactor in a nutshell.