...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
In the static library variant, customizing the main entry point is quite
troublesome, because the default test runner compiled into the static library
uses the obsolete initialization function signature. This requires you
to rebuild the Unit Test Framework static library
with the defined symbol BOOST_TEST_ALTERNATIVE_INIT_API
.
In the Boost root directory you need to invoke command
> b2 --with-test link=static define=BOOST_TEST_ALTERNATIVE_INIT_API
install
Warning | |
---|---|
This alteration of the static library will affect everybody else who is linking against the library. Consider using the obsolete test initialization function, which requires no rebuilding. Alternatively, it may be less intrusive to switch to the shared library usage variant instead. |
In one of the source files, you now have to define your custom initialization function with signature:
bool init_unit_test();
The default test
runner will use it to initialize the test module. In your source
code, you no longer define macro BOOST_TEST_MODULE
; instead, you
need to define BOOST_TEST_ALTERNATIVE_INIT_API
in the main file:
In exactly one file |
In all other files |
---|---|
#define BOOST_TEST_ALTERNATIVE_INIT_API #include <boost/test/unit_test.hpp> // init func: bool init_unit_test() { return true; } |
#include <boost/test/unit_test.hpp> // // test cases // // test cases // |
Note | |
---|---|
The reason for defining |