From: jweirich@... Date: 2001-10-22T15:23:04+09:00 Subject: [ruby-talk:22935] Re: First steps in unit testing >>>>> "Massimiliano" == Massimiliano Mirra writes: Massimiliano> I'm using rubyunit and it is my first experience Massimiliano> with unit testing in general. I'd like to hear some Massimiliano> opinions on a simple style matter. Massimiliano> I've seen three styles of writing the class that Massimiliano> does the testing: Massimiliano> 1) [attach_setup] Massimiliano> 2) [factory method] Massimiliano> 3) [inline] Massimiliano> Aside from the readability in example 3), that Massimiliano> however could go down as the test goes up in setup Massimiliano> requirements, are there significant advantages to Massimiliano> one way over the others? Start with the simpliest, style 3). As you add tests, you will notice common code being repeated. At that point, refactor your tests so that the common code can be captured in a setup function or a factory method. Don't try to anticipate generalities, wait until they actually occur. At least that's how I try to do it. -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)