Boost.Test > Components > The Unit Test Framework > Components > The Test Case > The automatic registration facility

# The automatic registration facility

##### Definition

defined in auto_unit_test.hpp

##### Description

This form of test cases is based on free function, but unlike class function_test_case you don't need to manually create and register them. Instances of the class function_test_case are created automatically by the framework at the point of test case definition and registered in single global test suite. This way you never forget to include any test cases - it's done on a fly. You doesn't need to supply init_unit_test_suite anymore. It's implemented by the framework and instantiated in one of the compilation unit. To notify which compilation unit should contain initialization function you need to define macro BOOST_AUTO_TEST_MAIN. In test with multiple compilation units one and only one should define above macro.

##### Construction

To use automatic registration facility you need to define a test case as a zero arity free function, but instead of usual void tc_name(), use following statement

BOOST_AUTO_TEST_CASE( tc_name )

BOOST_AUTO_TEST_CASE hides all the machinery used to implement automatic registration. The only requirements are that test case names are unique within compilation unit and no two test case definition are located on the same line.

##### Examples

    #define BOOST_AUTO_TEST_MAIN
    #include <boost/test/auto_unit_test.hpp>

    // _____________________________________

    BOOST_AUTO_TEST_CASE( test1 )
    {
        ...
    }

    // _____________________________________

    BOOST_AUTO_TEST_CASE( test2 )
    {
        ...
    }

    // _____________________________________