Art of Unit Testing

phil hunt zen19725 at zen.co.uk
Wed Aug 3 14:31:33 CEST 2005


On Tue, 02 Aug 2005 21:26:28 +0200, Christoph Zwerschke <cito at online.de> wrote:
>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.

Indeed. Running the tests should ideally take less than a few 
seconds. Any longer, and people won't use them so often.

-- 
Email: zen19725 at zen dot co dot uk





More information about the Python-list mailing list