Home > The Unit Test Framework > User's guide > Test organization > Nullary function based test case > Automated registration
PrevNext

Nullary function based test case with automated registration

To create a nullary free function cased test case, which is registered in place of implementation, employ the macro BOOST_AUTO_TEST_CASE.

BOOST_AUTO_TEST_CASE(test_case_name)

The macro is designed to closely mimic nullary free function syntax. Changes that are required to make an existing test case, implemented as a free function, registered in place are illustrated in the following example (compare with Example 5, “Nullary free function manually registered”):

Example 10. Nullary function based test case with automated registration

#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>

//____________________________________________________________________________//

BOOST_AUTO_TEST_CASE( free_test_function )
{
    BOOST_CHECK( true /* test assertion */ );
}

//____________________________________________________________________________//

Source code | Show output
> example --log_level=test_suite
Running 1 test case...
Entering test suite "example"
Entering test case "free_test_function"
Leaving test case "free_test_function"; testing time: 16ms
Leaving test suite "example"

*** No errors detected

With this macro you don't need to implement the initialization function at all. The macro creates and registers the test case with the name free_test_function automatically.


PrevUpHomeNext