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.


About Aaron Glasenapp

I am a freelance Web/Rails developer and a hard core recreational mathematician.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: