Is it possible to have the fixture initialized only once and use it in multiple test cases within the same test suite? In the following example, fixture is constructed and destructed multiple times:
struct F {
F() : i( 0 ) { BOOST_TEST_MESSAGE( "setup fixture" ); }
~F() { BOOST_TEST_MESSAGE( "teardown fixture" ); }
int i;
};
BOOST_FIXTURE_TEST_SUITE( s, F )
BOOST_AUTO_TEST_CASE( test_case1 )
{
BOOST_CHECK( i == 1 );
}
BOOST_AUTO_TEST_CASE( test_case2 )
{
BOOST_CHECK_EQUAL( i, 0 );
}
BOOST_AUTO_TEST_SUITE_END()
But I want the fixture to be constructed only once as the test suite begins and shared among all the test cases within it. Is it possible? The destructor would be called after exiting the test suite.
I am using Boost Test Framework but have no problem using other frameworks like UnitTest++.