Art of Unit Testing

Peter Hansen peter at engcorp.com
Wed Aug 3 09:44:02 EDT 2005


Christoph Zwerschke wrote:
> I think wanting to have a more global initialization 
> indicates that you are acutally not wanting to do a "unit" test, but a 
> more global test of the overall system, something like an acceptance or 
> integration test, i.e. you are trying to abuse unittest for something it 
> was not intended to be used for.

As I mentioned in another post just now, we use unittest for acceptance 
testing and other kinds of high level testing.  We also try very very 
hard to follow XP rules of thumb in terms of keeping our setup code 
short and fast.  As a result, we generally don't need to do what you are 
finding you need to do, and unittest is quite adequate.  Don't try to 
make the point that unittest cannot do acceptance testing; it's _your_ 
acceptance tests which are the issue here, and I agree unittest was not 
designed specifically to do exactly what you want.  It also wasn't 
designed to prevent it, but really just to be uninvolved in this issue.

The whole JUnit family wasn't designed to solve all testing problems, 
but (I infer, from long use) to be a fairly simple and therefore general 
approach.  It doesn't have a huge array of features supporting all 
possible approaches to testing, but it's simple enough not to prevent 
you from doing what you need to do in most cases.

If you want a test framework with built-in support for what you need, 
that's fine.  In programming, one size doesn't fit all.

-Peter



More information about the Python-list mailing list