How about, instead of retrofitting tests to existing features, you test-first the existence and behavior of this new type? Then test-first the database migration that copies your production data into it...
wel I started out by trying to create my tests first, but I just got
stuck so I decided to write the model validations.
Thats my biggest problem at the moment, I have never developed through
TDD.
And the main problem isn't realy whether to develop or test first, but
how to build my tests.
The logic of my tests has to be wrong, becouse eather way, they fail.
I suggest starting with a very simple test and get that working first. Use the debugger to find out what is going wrong if you cannot get it to behave correctly.
I suggest starting with a very simple test and get that working first. Use the debugger to find out what is going wrong if you cannot get it to behave correctly.
Further, if you cannot _briefly_ get the test working, comment it out and write a simpler test, maybe on another feature.
Test the models first, for example.
The goal here is breadth-first, not depth first. The more tests you write, the more "muscle memory" you develop, and the easier new tests get. You might come back to this validation problem, for example, and just knock it out easily...
In October, I gave a quick intro to Rails with test-driven development
at a local code camp. I distributed a PDF to the group that walks a
newcomer through test-first development. Perhaps it would help you get
a handle on how to get started.
This link contains a link to the PDF as well as a link to the finished
project on github.
I've been working on my skills the last couple of days. I have shown
some improvements but as Colin stated, it is not something that you
develop over night. It takes time and practice. But I notice that I'm
making progress (maybe less then I expected, but still ).
Brien, thanks for the input. I'm glad to see all the good work people
make with writing information for newcomers.