Description
The class
TestFixture (see Figure C-23)
defines the interface of a test fixture. TestCase
is descended from TestFixture, so every test
object is implicitly a test fixture. However, a test object is truly
being used as a fixture only if it has multiple test methods that
share objects. Philosophically, a fixture is a test environment, and
the test methods interact with the environment to test different
behaviors.
The TestFixture methods setUp() and tearDown( ) are used to initialize
and clean up the fixture's shared objects. When
there are multiple test methods in the fixture, setUp() and tearDown( ) are called for each
one. This ensures test isolation by making sure the fixture is in the
same state for each test.
TestFixture belongs to the namespace
CppUnit. It is declared and implemented in
TestFixture.h.
Declaration
class TestFixture
Constructors/Destructors
- virtual ~TestFixture( )
A destructor.
Public Methods
- virtual void setUp( ) {}
Initializes the fixture's shared objects. The
default implementation does nothing.
- virtual void tearDown( ) {}
Cleans up the fixture's shared objects. The default
implementation does nothing.
Protected/Private Methods
None.
Attributes
None.
|
No comments:
Post a Comment