Test driven development advice

I am attempting to use Test Driven Development for the first time and
was hoping for a little advice. I am just starting a new section of
the website that will ultimately contain a couple controllers and
about 6 models. If I am going to write my tests before any code, I
need to decide whether to start writing test with the models or the
controllers. Do I write the test for the models and in the course of
writing the code that will make them succeed build the models or
should I start with the models, get them all working and then move on
to the controllers? My guess is you can do it either way but I
thought perhaps some folks who have worked in TDD environments might
have some wisdom to share.

Thanks!

drewB wrote:

I am attempting to use Test Driven Development for the first time and
was hoping for a little advice.

Great! Give serious consideration to rSpec, if you haven’t already, and
completely avoid Rails’ fixtures (use Machinist or similar instead).

I am just starting a new section of
the website that will ultimately contain a couple controllers and
about 6 models.

You haven’t written tests yet. You don’t really know how many of either
it will contain. Don’t do this level of design before writing tests.

If I am going to write my tests before any code, I
need to decide whether to start writing test with the models or the
controllers. Do I write the test for the models and in the course of
writing the code that will make them succeed build the models or
should I start with the models, get them all working and then move on
to the controllers? My guess is you can do it either way but I
thought perhaps some folks who have worked in TDD environments might
have some wisdom to share.

You certainly can do it either way. I think in most cases, I would try
to start by writing Cucumber features to establish how the application
should present itself to the user, then write whatever classes (and unit
tests) prove necessary to implement those features.

Thanks!

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Thanks for the tips. I just got the beta version Pragmatic Bookshelf
Rspec and am working through it now.

On Sep 27, 4:29 pm, Marnen Laibow-Koser <rails-mailing-l…@andreas-