Needed class whose instances are many test cases

Ben Finney bignose+hates-spam at benfinney.id.au
Fri Nov 11 18:51:34 EST 2005


Roy Smith <roy at panix.com> wrote:
> Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:
> > Test cases should each run individually, from a known state, and
> > not depend on any other tests. You can define a fixture for
> > several tests in the unittest.TestCase methods setUp() and
> > tearDown(), to establish and clear up respectively for each test.
> 
> In general, I certainly agree with the above.  The problem is that 
> sometimes setup is so expensive, it becomes impractical to do a full 
> setup/teardown cycle for each test.

That's what mock objects are for. The test fixture should be minimal,
having only the interface needed to test that the production code does
what it should, with almost no functionality behind that interface.

    <URL:http://pmock.sourceforge.net/>

-- 
 \            "I always had a repulsive need to be something more than |
  `\                                           human."  -- David Bowie |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list