Unit Testing Examples

Thomas Guettler guettli at thomas-guettler.de
Tue Nov 18 10:26:38 EST 2003


Am Mon, 17 Nov 2003 09:10:32 -0800 schrieb Tom Verbeure:

> Hello All,
> 
> so I'm now convinced that unit testing is really the way to go and I
> want to add it to an existing project. The first thing that I find
> out, is that, well, it's hard work. Harder than writing the real
> functional code.

If you are using objects which are containers for
other objects, you could do it like this:

Every object gets a method called "unittest". This performs
a unittest on its own data, and then calls unittest() for
all child objects.

This way you can check all objects by calling unittest for the root object,
or call the method for only a part.

Be sure to do no recursion if you have circular data.

 thomas








More information about the Python-list mailing list