[I've been meaning to mention this for some time now. But I've been
eaten alive by my house, and have been spending my train rides lately
hacking together new emacs programming modes.]
At work, just about every library has its own set of unit-tests. If
you've never heard of a unit-test, the idea is this: take a lib
you've written, and put it through its paces.
One should attempt to test every method in a class (yues, even the
protected and private ones), making sure it behaves as expected. One
should also make sure it correctly handles oddball conditions (bad
parameters, weird values, etc).
Unit tests are wonderful things to run through profilers (such as
Purify) to check for memory leaks.
Need to handle a large set of possible options? Use a Monte-Carlo
simulation. I can provide you with a class to generate basic random
entities (Including random pseudo-text that's verbally pronouncable).
I can also help out with creating Monte-Carlo simulations (that was a
main tool in my doctoral research).
Unit tests have an additional advantage: they catch code-breaking
patches *before* you run the full program. The only time you change a
unit test is if you make fundamental changes to the underlying
methods.
Example: int foo(N) returns an index (don't ask me to what) between
0...N-1. Someone submits a patch to foo() that breaks the unit test.
The patch is therefore bad. Someone else submits a patch that changes
the returned index range to 1...N. This also breaks the unit test,
but it should - the patch intentionally alters the fundamental
behavior of foo().
Who initially creates the unit test? Well, for new code, whoever
wrote the new method/class/feature. For old code, we should divide up
the work. Writing unit tests is also a good way for new devvies to
cut their teeth on code in the CVS repository.
Who maintains/changes the unit tests? Well, if a patch changes
fundamental behavior in a method or class, the patch author should
*NOT* be the one to change the unit test. Someone else should do
that, just to maintain an independent perspective.
--
John Weiss