Boost logo

Boost Users :

From: Steve Hutton (yg-boost-users_at_[hidden])
Date: 2003-09-02 20:32:40

In article <024001c36f45$8180bbf0$04fda8c0_at_[hidden]>,
Dean Brettle wrote:
> Since no one has mentioned them yet, there are at least three potential advantages to setUp()/tearDown() over constructors/destructors:
> 1. If you call virtual member functions from within setUp() and tearDown(), those calls will be serviced by the most derived class. This is useful when some of the setup which varies in derived classes needs to occur before some part of the common setup.

> 2. The test runner only calls the setUp()/tearDown() method of the most derived class. setUp()/tearDown() in base classes are not called. This is useful when the base and derived classes share a lot of test methods but the setup for the base class is either unnecessary or inappropriate for the derived class.

What about using containment instead then, if you only want to
share test method implementations, but not the construction/

> 3. setUp()/tearDown() are called immediately before and after the test method runs. The constructor for a test fixture is typically called when it is added to the test suite which might be long before it is run. That means that the constructor is not an appropriate place to initialize global environmental conditions (eg impersonate another user, or change the working directory).

It may be that the test fixture constructors are called ahead of
time in some designs, but that doesn't have to be the case. For
example, TUT does not do it that way.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at