Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the master branch, built from commit fa33539dff.

Customizing the module's initialization function

In this usage variant, you do not define macro BOOST_TEST_MODULE and instead provide the definition of function init_unit_test. This is going to be the custom initialization function. The default test runner will use it to initialize the test module.

Example: using custom initialization function


#include <boost/test/included/unit_test.hpp>
#include <iostream>


bool init_unit_test()
  std::cout << "using custom init" << std::endl;
  return true;


> custom_init
using custom init
Running 1 test case...
test.cpp(7): error: in "test1": check false has failed

*** 1 failure is detected in the test module "Master Test Suite"
[Note] Note

Because we overwrote the default initialization function, it does no longer assign any name to the master test suite. Therefore the default name ("Master Test Suite") is used.

[Note] Note

The reason for defining BOOST_TEST_ALTERNATIVE_INIT_API is described here.