Art of Unit Testing

Christoph Zwerschke cito at online.de
Tue Aug 2 21:26:28 CEST 2005


Björn Lindström wrote:
>>Would it make sense to add "globaleSetup" and "globalTearDown" methods
>>to the TestCase class?
> In general that's not such a good idea.

I completely agree and I think it makes a lot of sense that unittest 
calls setUp and tearDown for every single test. However, the fact that 
this is *generally* the best way doesn't exclude the fact that there are 
*exceptions* when it makes sense to setUp and tearDown not for every 
test, e.g. when it is absolutely sure that the fixture cannot be 
destroyed by the individual tests or when creating the fixture takes too 
much time. I already gave the example of creating database connections 
or even creating/importing whole databases. My question was, how do I 
handle these cases with the standard lib unittest?

According to the "extreme programming" paradigm, testing should be done 
several times a day. So a requirement for extreme programm is that tests 
are fast enough. If the testing needs too much time, people are 
discouraged to test often.

-- Christoph



More information about the Python-list mailing list