obsolete_init_func.qbk 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. [/
  2. / Copyright (c) 2003 Boost.Test contributors
  3. /
  4. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /]
  7. [section:obsolete_init_func The obsolete initialization function]
  8. For backwards compatibility, the __UTF__ also allows the customization of an initialization function of a different type.
  9. This is called the ['obsolete initialization function]. Its signature is:
  10. ```
  11. boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]);
  12. ```
  13. The original design of the __UTF__ required of the programmer to implement it. It was intended to initialize and return
  14. the __master_test_suite__. No [link ref_BOOST_AUTO_TEST_CASE automatic test case registration] was available at that
  15. time. The null-pointer value was considered an initialization error.
  16. In the header-only usage variant, you fall back to the obsolete initialization function signature by omitting the
  17. definition of macro __BOOST_TEST_ALTERNATIVE_INIT_API__ in test module code.
  18. [bt_example custom_obsolete_init..using obsolete initialization function..run-fail]
  19. In the static-library usage variant, you need to omit the definition of macro __BOOST_TEST_ALTERNATIVE_INIT_API__ in test
  20. module and compile the __UTF__ static library without the compilation flag __BOOST_TEST_ALTERNATIVE_INIT_API__ (this is
  21. the default).
  22. In the shared-library usage variant, it is not possible to use the obsolete initialization function.
  23. Even if you decide to us the obsolete initialization function, it is recommended that:
  24. # You always return a null-pointer value and install the master test suite via
  25. [memberref boost::unit_test::test_suite::add `test_suite::add`] as illustrated
  26. [link ref_BOOST_TEST_CASE here]. The current framework does no longer treat the
  27. null-pointer value as failure.
  28. # You signal the failure by throwing [classref boost::unit_test::framework::setup_error] exception.
  29. # You access the command-line arguments through the interface of the __master_test_suite__,
  30. and ignore the function's arguments `argc` and `argv`.
  31. [caution The obsolete initialization function is deprecated as its name indicates. It is recommended to migrate
  32. to the new API, and rely on the automated test unit registration and [link boost_test.tests_organization.fixtures
  33. fixtures] (including [link boost_test.tests_organization.fixtures.global global fixtures]) for other set-up. ]
  34. [endsect] [/section:obsolete_init_func]