--- Albert Wagner <alwagner / tcac.net> wrote:
> I am curious about how others work;  And how unit 
> testing is really used:   
> as a predefinition of specs or tacked on 
> after-the-fact to convince others that you 
> are PC (Politically Correct).

When I create unit tests, it's generally in a Test-First
setting. I write just enough test code to where I have a
failing assert. Then I write just enough production code to
pass that test. (Which is usually returning a hard-coded
value).

Then I write another couple lines of test code. Then I
write another couple lines of production code. The process
repeats. Whenever I see a way to improve my implementation,
I refactor. The tests assure me that I haven't broken any
existing functionality.

This is similar to the "sculpting" approach you described,
except that I'm writing bits of test code in between
writing bits of production code, while creating that first
(rough) implementation.

Writing tests after the code is finished is SOOOOO much
harder. I don't do that. Trying to write an entire body of
tests before you write any code is also SOOOOO much harder.
I don't do that either.

When I write code without tests, I often end up writing
code that just doesn't need to be written. Test-first helps
me avoid gold-plating, and to stay focused on the immediate
task I am trying to complete.

On a Ruby note, RubyUnit is by far the best unit test
framework I have tried (compared to JUnit, for example). I
haven't tried Lapidiary yet, but have high hopes that it
may be even better. Kudos and thanks to the developers of
both of those packages!

Kevin


__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1