Boost
C++ Libraries
...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
This version of Boost is under active development. You are currently in the master branch. The current version is 1.92.0.
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.
|
Code |
|---|
#define BOOST_TEST_ALTERNATIVE_INIT_API #include <boost/test/included/unit_test.hpp> #include <iostream> BOOST_AUTO_TEST_CASE(test1) { BOOST_TEST(false); } bool init_unit_test() { std::cout << "using custom init" << std::endl; return true; } |
|
Output |
|---|
> 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 |
|---|---|
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. |
For reporting errors that may occur during the initialization,
false
(valid only for the new API only, see BOOST_TEST_ALTERNATIVE_INIT_API)
std::runtime_error
or boost::unit_test::framework::setup_error
An error reported in this function aborts the execution of the test module.
![]() |
Note |
|---|---|
The reason for defining |