On Tue, Jan 28, 2003 at 03:18:04AM +0900, Kent Dahl wrote:
> To the OP, Mauricio FernŠŌdez, 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. 

The way I had written it, I couldn't easily separate the handshake from
the rest. I guess this reflects a number of things:
 * that I should have writen the test before coding (instead of at the
   same time)
 * that Unit Testing really helps me think on the interface better than
   some simple UML and stuff (which I actually took the time to make :)
 * that I still have a lot to learn on Unit Testing 
 
> > 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).

What about tests that rely on some state of the (in this case) protocol?
Can I chain them as suggested in another post like

 def test_dosomeopt
    ....
 end
 
 def test_dosomething
     test_dosomeopt
     ....
 end

?

Is there a good reference on this for newcomers to Unit Testing? If
possible not too focused on XP, as those tend to get quite abstract and
anyway there's a couple things about XP I just cannot do like pair prog. ...

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

'Ooohh.. "FreeBSD is faster over loopback, when compared to Linux
over the wire". Film at 11.'
	-- Linus Torvalds