Home | Libraries | People | FAQ | More |
BOOST_GLOBAL_FIXTURE(
name
)
declares a global fixture that is constructed before executing any test
cases and is destroyed after executing all test cases. If more than one
global fixture is defined in a single source file, the fixtures are constructed
in the order they appear in the source file and destroyed in the reverse
order. If global fixtures are defined in multiple source files, the order
in which global fixtures are initialized between source files is implementation
dependent.
Because global fixtures are not created and destroyed for each test case,
they represent shared state that prevents test cases from executing independently
from each other. For this reason, test case fixtures created with BOOST_FIXTURE_TEST_CASE
and test suite fixtures created with BOOST_FIXTURE_TEST_SUITE
are preferred over global fixtures.
struct global_fixture { global_fixture() { std::cout << "global setup\n"; } ~global_fixture() { std::cout << "global teardown\n"; } }; BOOST_GLOBAL_FIXTURE(global_fixture);