On Sat, 01 Dec 2001 13:46:42 GMT, olczyk / interaccess.com (Thaddeus L
Olczyk) wrote:

>For a long time I've been writing unit tests with my code.
>I have a reputation among of friends of writing meticulous
>code and of meticulously testing it. I have been so determined 
>to not release code until it was well tested, that at times I have
>suffered professionally from it.

I'm guessing that suffering was due to holding code back when people
wanted it. If my guess is wrong, the following may not apply:

Have you tried testing as or before you code, and releasing your
tested code incrementally, say every day? When I do that, I find that
by far the bulk of the value of my code is available for us any time
the other guy wants it.
>
>In all that time, I have never once been able to produce a system
>of tests that meets three criteria: the tests run automatically, the
>tests are comprehensive, and the tests are easily maintainable.
>At this point I am strongly beginning to wonder whether such a
>system is possible.

That's interesting. I would say that never before test-first have I
accomplished it, and I wrote a lot of software and a lot of tests the
other way. Yet test-first makes it easy. Here's a sketch of how it
happens. 

1. You start with a clean text buffer: no code.
2. You have something in mind you want your program to do. Something
tiny: the first little bit.
3. You write an automated test to prove that your clean text buffer
doesn't have that feature.
4. For a while the test doesn't compile. You add just enough code to
the buffer to make it compile (typically a class definition or
function declaration).
5. For a while the test doesn't work. You add just enough code to the
buffer to make the test run.

At this point, you have tests (1) that run automatically, that are
comprehensive, and (it turns out, I have no proof for this) they're
easy to maintain.

Then you think of one more little bit the program might do. You write
another automated test to see if the program does it ...

As odd as it sounds, this really works. It does take practice, and you
do have to go in TINY steps. No, tinier than you are thinking. 
T_I_N_Y.

Since you like tests and tested code, you might like to give it a try.
There's a small example in XP Installed, and Chet and I give
demonstrations at various conferences. The Spring Software Development
is a strong possibility for the next public session.

Regards,
>
>So I offered a challenge to those that support heavy unit testing.
>In particular to the XP community. Produce a "proof-of-concept"
>for unit testing by taking some open source project and adding unit
>tests. I also suggested that if the person needed to he could rewrite
>the project to facilitate testing.  ( Let me say that this also can be
>loosely interpreted to include writing an open source project. Some
>advocates say that the only way to implement a unit test system is to
>write it before you write the code. )


Ronald E Jeffries
http://www.XProgramming.com
http://www.objectmentor.com