From: Dave Bass Date: 2008-08-04T23:07:36+09:00 Subject: Re: unit testing advice So should we write code first, or tests first? Tests are themselves bits of code, so they may have bugs in them. No really, I've put them there myself so I know. It's galling to discover that your "real" code is correct but the test is failing because you got it wrong. Duh, I was looking for the bug in completely the wrong place! This realisation puts code and tests on a more parallel footing. The upshot is that code and tests should be written in parallel as far as possible; certainly at method level. Most of the time I like to write a test or two to exercise the few lines of code I've just written. By few I mean typically 5..10. I like to write my code first, tests second. Otherwise how do I know what I'm supposed to be testing? (There's no spec, I make things up as I go along. This is a hobby, not work.) Other people probably do things differently. :-) Dave -- Posted via http://www.ruby-forum.com/.