[Tutor] I don't get it
Yigal Duppen
yduppen@xs4all.nl
Sat, 21 Sep 2002 02:49:38 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> According to Extreme Programming you should always write tests
> before writing the code you try to test. When your code passes
> all your tests you stop coding, since then you are done. See
> http://www.thinkware.se/cgi-bin/thinki.cgi/ExtremeProgramming
Hmm. Talking about lightbulbs erupting over heads... I never got the idea of
'test first, code later' until I read Chapter 14 of "Extreme Programming
Explained". By semi-transcribing an imaginary chat between to developers
testing and coding, the authors managed to have the equivalent of 10 100Watt
bulbs over my head ;-)
Since that time, I'm quite a strict follower of the test->code paradigm.
> When you refactor you *never* change your tests. They should
> all run both before and after each refactoring.)
This is of course a slightly optimistic view.
For example, one of the simplest refactorings is Rename Method. I can
guarantee that after applying this refactoring, at least one of your tests
will fail :)
When you get to the more elaborate refactorings that modify your code
structure, this gets even worse. That's why the refactorings in the Book are
all presented as algorithms with very simple steps -- you are allowed to
adjust your tests, as long as you _only_ change tests as a direct result of
applying one of the refactoring-steps.
> A development session using unit testing and refactoring is
> sescribed here:
> http://www.xprogramming.com/xpmag/refactoringisntrework.htm
It's a bit like the chapter 14 mentioned above. But the nice thing about XP
Explained is that their test case is far from trivial; yet-another-stack
example just doesn't seem to thrill me...
> I then have a small script
> that will run all the test scripts in a project directory.
Ahhh. No greater joy than running such a script and seeing the 'OK's scroll
over your screen (verbose=2 setting in unittest.TestRunner). Sometimes when
I'm stuck I just hit it over and over again, to have something soothing to
stare at... I know... I need a life :)
YDD
- --
http://www.xs4all.nl/~yduppen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9i8IiLsKMuCf5EdwRAiyaAKC1qrohdDzOLOEq5ZR3kBmuwqX7+ACeILCS
TA59kiWGiNbnUy71fdvGEDs=
=kCUc
-----END PGP SIGNATURE-----