We may want multiple tests that all use the same Money. In such cases, rather than setting up and tearing down objects for each unit test, it may be convenient to add some setup that is constant across all the tests in a test case. In the Extreme Programming (XP) approach to unit tests, each such setup is called a test fixture.
A fixture is created by defining a setup and/or a teardown function, and associating it with a test case. There are two kinds of test fixtures in Check: checked and unchecked fixtures. These are defined as follows:
setup()
function is run, if defined. After each unit test, the teardown()
function is run, if defined. Since they run inside the forked address
space, if checked fixtures signal or otherwise fail, they will be
caught and reported by the SRunner.
setup(), if defined, is run before the test case is
started. The unchecked teardown(), if defined, is run after the
test case is done.