Test cases always run with separate instance?

Bernhard Herzog bh at intevation.de
Fri Mar 19 15:13:27 CET 2004


Martin Schulze <joey at infodrom.org> writes:

> Hi!
>
> I wonder if a class containing several test functions needs to be
> created and destroyed for each test, so that no object data can
> survive from one test to another.

The class will be instantiated once for each of the test methods.  This
happens pretty early on IIRC and the instances live until the end of the
test suite run.  Each of the instance will only call one of the test
methods.  If you build you data structures in setUp and destroy them in
tearDown each of the instances will get their own copy of the data
structures unless you do something explicitly to share them.

The docs try to express this too, I think when they write (below code
for a class with two test methods and self.widget created in setUp and
destroyed in tearDown):

   Here we have not provided a runTest() method, but have instead
   provided two different test methods. Class instances will now each
   run one of the test*() methods, with self.widget created and
   destroyed separately for each instance. 

  Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Skencil                                http://sketch.sourceforge.net/
Thuban                                  http://thuban.intevation.org/




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)