asplake

Monday, January 02, 2006

40 tests, 115 assertions, 0 failures, 0 errors

I have a fairly complete set of unit tests for my model now. I found one bug in the process, and tidied up my API a bit when I found the tests themselves looking clunky. Coverage is good enough now that I can change something and rely on the tests to pick up any knock-on changes that I've missed.

My only caveat is that I have significantly more test code than model code now, and I might have to redress this a bit with some refactoring. I'm thinking along the lines of some helpers for testing STI, acts_as_list, :dependent => :destroy, etc.

I made a start today on functional tests. With unit testing, I was familiar enough with the concepts but new to doing it in Ruby and with Rails (both of which make it really easy). With functional testing, I'm not too sure where to stop - I'm aiming to test most or all paths through the controllers, but how thoroughly should I test the views? Perhaps a re-read of Mike Clark's chapter in the excellent Agile Web Development with Rails is in order.

Technorati tag:

1 Comments:

  • Where to stop testing is a tricky question which I wish I knew the answer to.

    I try to test each feature so it succeeds once and fails one or more times in different ways. It's pretty stringant and I have to change code a bit but I think it pays off in the long run.

    I always expect way more test code then model code too.

    By Blogger Ben Schleimer, at 1:19 pm  

Post a Comment

<< Home