title: Boost test case and suite fixtures in manually defined suite tree
body: <p>Using Boost 1.46.1 on Windows x86, Android TI 2.2</p>
  
  <p>I have defined my own test suite tree, since I need the user to choose order of the tests. although I'm aware the tests should be independent, this is a requirement. The test suite tree was redefined using my own implementation of <code>test_suite* init_unit_test_suite(int, char**)</code>.</p>
  
  <p>For automated test cases and automated test suites, there are Boost macros: <code>BOOST_FIXTURE_TEST_CASE</code> and <code>BOOST_FIXTURE_TEST_SUITE( suite_name, F )</code>. These macros register the function to the <code>framework::master_test_suite()</code>, which is undesired behavior in this case.</p>
  
  <p>Global fixture (<code>BOOST_GLOBAL_FIXTURE(fixure_name)</code>) remains unaffected in manual test suite definition.</p>
  
  <p>I would like to use fixtures in Boost Unit Testing Framework for manually defined test suites and cases. A neat way.</p>
  
  <p>There are some workarounds:</p>
  
  <ul>
  <li>Test Suite Fixture - can be defined as a first and last test among
  it's children suites/cases. This however affects the test results and
  acts as a separate test, which is not really a fine solution.</li>
  <li>Test Case Fixture - by wrapping a scoped instance around the test case
  function.</li>
  </ul>
  
  <p>Is there any other, cleaner and nicer solution to my problem? I don't really have resources to dig deep into Boost library. On the other hand, I don't want to significantly decrease the quality and readability of the code on my side.</p>
  
  <p>Regards, LK</p>
  
  <pre><code>#include &lt;boost/bind.hpp&gt;
  #include &lt;boost/smart_ptr.hpp&gt;
  #include &lt;boost/test/unit_test.hpp&gt;
  using namespace boost::unit_test;
  
  BOOST_GLOBAL_FIXTURE(GFixture);
  
  test_suite* init_unit_test_suite( int, char** )
  {
      test_suite* ts1 = BOOST_TEST_SUITE( "Suite1" );
  
      boost::shared_ptr&lt;TestClass1&gt; test1 ( new TestClass1 );
      ts1-&gt;add( BOOST_TEST_CASE( boost::bind(&amp;TestClass1::Run, test1)));
      boost::shared_ptr&lt;TestClass2&gt; test2 ( new TestClass2 );
      ts1-&gt;add( BOOST_TEST_CASE( boost::bind(&amp;TestClass2::Run, test2)));
      boost::shared_ptr&lt;TestClass3&gt; test3 ( new TestClass3);
      ts1-&gt;add( BOOST_TEST_CASE( boost::bind(&amp;TestClass3::Run, test3)));
  
      framework::master_test_suite().add( ts1 );
      return 0;
  }
  </code></pre>
  
  <p>Unit Test Framework: User's guide<br/>
  <a href="http://www.boost.org/doc/libs/1_46_1/libs/test/doc/html/utf/user-guide.html" rel="nofollow">http://www.boost.org/doc/libs/1_46_1/libs/test/doc/html/utf/user-guide.html</a></p>