From: Kent Dahl Date: 2003-01-28T03:18:04+09:00 Subject: Re: Test::Unit -> order of tests? ahoward wrote: > > On Tue, 28 Jan 2003, Michael Garriss wrote: > > > IMHO, it would be nice if they were run in the order they were defined. > > agreed. Not arguing that it would be nice, since it is possible to scan the "dot-line" and know where to go looking, but please do _not_ rely on test run order for anything serious. It is a bad idea and I think hardcore unittesters would run over you with a TestRunner if you do. (Been there, done that, red CVS tree all my fault, but I could atleast blame it on C++ :-P) Anything that needs to be initalized or cleaned up should be in setup or teardown. If not, you're not doing "proper" unittesting, but something akin more to acceptance or integration testing, IMHO. To the OP, Mauricio Fern�ndez, who wrote: > There's some hand-shaking involved > at the beginning which _needs_ to be done before anything else. The > problem is I'd like to test that too, Test the handshaking separately in its own test. Whatever you do, do not use the test that does the handshaking set anything up that the other tests would need. > but I don't know if I can rely on > any order in the execution of the tests. OTOH, I don't know if it's OK > to do everything in #setup and do the assertions right there. Bad idea. Setup shouldn't contain assertions meant to unittest something. Anything failing in setup is an "Error", not a "Failure", if I remember my unittesting parlance correct. I would suggest you split in two testcases, one that tests the handshaking exclusively and another testcase where setup does the handshaking (but does not test it) for the conveniece of the other parts you want to test, and just plain assumes that handshaking works (you have another unittest that should catch it if it doesn't). -- (\[ Kent Dahl ]/)_ _~_ __[ http://www.stud.ntnu.no/~kentda/ ]___/~ ))\_student_/(( \__d L b__/ NTNU - graduate engineering - 5. year ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)