On 14 May 2009, at 14:20, Phlip wrote:

Matt Wynne wrote:

I've got a reason. You're coupling the tests for this simple little controller class to all the infrastructure and dependencies needed to write the record to the database and reload it again. As easy as Rails makes it for us to manage our database schemas, gratuitously introducing dependencies in your code like this is a bad habit to get into. It can lead to tests that are fragile to failing when code is changed far away from the place they're apparently testing. The tests also run slowly, which makes working on systems written like this boring.

The point of unit tests (which include the alleged "functional tests" in Rails) is to fail more often than production code would fail. Not less often.

Yep, I agree that would be silly.

On the other hand, if the tests fail for no good reason all the time because they're fragile, people may stop listening to them, and maybe eventually stop writing them. The argument I'm making is really just for slowing down and taking a little more care, with the eventual benefit of tests that are trustworthy and easy to maintain. I would imagine that's your goal too, but we apparently have different approaches :)

Matt Wynne
http://beta.songkick.com
http://blog.mattwynne.net



_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to