ahoward 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).
</unittesting_preaching_mode>
···
On Tue, 28 Jan 2003, Michael Garriss wrote:
–
([ 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)