I know I'm late to this question, but I just stumbled across it and it looked so lonely...
To understand this restriction, you have to understand how Boost Tests originally worked. (It still can work this way, but back then there were no BOOST_AUTO_...
macros and you had to do it this way.)
From the docs:
class test_class {
public:
void test_method1()
{
BOOST_CHECK( true /* test assertion */ );
}
void test_method2()
{
BOOST_CHECK( false /* test assertion */ );
}
};
//____________________________________________________________________________//
test_suite*
init_unit_test_suite( int argc, char* argv[] )
{
boost::shared_ptr<test_class> tester( new test_class );
framework::master_test_suite().
add( BOOST_TEST_CASE( boost::bind( &test_class::test_method1, tester )));
framework::master_test_suite().
add( BOOST_TEST_CASE( boost::bind( &test_class::test_method2, tester )));
return 0;
}
This was a bit cumbersome, because every time you add a test function, you had to change code in two seperate locations (the definition of the function and the registering with the test suite). The registering is also somewhat non-intuitive.
That is why they introduced the BOOST_AUTO_TEST_SUITE
and BOOST_AUTO_TEST_CASE
, which are doing this for you.
The parameter you pass to BOOST_AUTO_TEST_SUITE
is, of course, the name of the class (test_class
above). The parameter to BOOST_AUTO_TEST_CASE
is the name of the test function (test_method1()
and test_method2()
above).
So no, those may (of course) not be identical to the class and functions you are testing. You can use namespaces for this, but personally I prefer simply suffixing the class name with Tu
(or _tu
if you aren't into CamelCase naming), and using that for the test suite.
I hope this helps.