![]() |
Home | Libraries | People | FAQ | More |
In the static library variant, customizing the main entry point is quite
troublesome, because the definition of function main
is already compiled into the static library. This requires you to rebuild
the Unit Test Framework static library with the defined
symbol BOOST_TEST_NO_MAIN
. In the Boost
root directory you need to invoke command
> b2 --with-test link=static define=BOOST_TEST_NO_MAIN
define=BOOST_TEST_ALTERNATIVE_INIT_API
install
![]() |
Warning |
---|---|
This removal of entry point definition from the static library will affect everybody else who is linking against the library. 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 entry point,
and invoke the default test
runner unit_test_main
manually with the default initialization
function init_unit_test
as the first argument. There is no need to define BOOST_TEST_NO_MAIN
in your source
code, but you need to define BOOST_TEST_ALTERNATIVE_INIT_API
in the main file:
In exactly one file |
In all other files |
---|---|
#define BOOST_TEST_MODULE test module name #define BOOST_TEST_ALTERNATIVE_INIT_API #include <boost/test/unit_test.hpp> // entry point: int main(int argc, char* argv[], char* envp[]) { return utf::unit_test_main(init_unit_test, argc, argv); } |
#include <boost/test/unit_test.hpp> // // test cases // // // test cases // |
![]() |
Note |
---|---|
The reason for defining |