Unit Tests

Each class must have unit tests. Every class’s unit tests must score 100%. On C3, we use Kent Beck’s public domain testing framework, augmented with a GUI that runs all the tests and shows the percent correct. At this writing, there are over 1300 unit tests, and they all run at 100 percent.

We recommend that unit tests be written before the class is written. This is a good way to focus attention on what the class is really about. In any case, a class isn’t done until its unit tests are in the test suite.

When classes are released, all unit tests must be running at 100 percent. All. That is, if the changes you make break the unit tests for some other class, the problem must be resolved before you release.

On the contrary, what if I’m not the one who broke the test, or what if someone is using my class incorrectly?

To emphasize the point: all the unit tests must run at 100 percent, all the time.


1997, 1998, Ronald E Jeffries
ronjeffries@acm.org
http://www.xprogramming.com