entry_point_overview.qbk 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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:entry_point_overview Test module's entry point]
  8. Typically, every C++ program contains exactly one definition of function `main`: the program's /entry point/.
  9. When using the __UTF__ you do not have to define one. Function `main` will be generated for you by the framework.
  10. The only thing you are required to do in case your program consists of more than one translation unit (`cpp` file)
  11. is to indicate to the framework in which of the files it is supposed to generate function `main`.
  12. You do it by defining macro __BOOST_TEST_MODULE__ before the inclusion of any of the framework files.
  13. The value of this macro is used as a name of the [link ref_test_module test module] as well as the
  14. [link boost_test.tests_organization.test_tree.master_test_suite master test suite].
  15. The reason for defining function `main` for you is twofold:
  16. # This allows the __UTF__ to perform some custom [link boost_test.adv_scenarios.test_module_init_overview ['test module initialization]].
  17. # This prevents you defining `main`, and accidentally forgetting to run all the test (in which case running the program would incorrectly indicate a clean run).
  18. By default, the test module's entry point is defined with signature:
  19. ```
  20. int main(int argc, char* argv[]);
  21. ```
  22. It calls [link boost_test.adv_scenarios.test_module_init_overview ['test module initialization]] function, then calls the
  23. [link boost_test.adv_scenarios.test_module_runner_overview ['test module runner]] and forwards its return value to environment.
  24. The default entry point is sufficient in most of the cases. Occasionally, a need may arise to declare an entry point with a
  25. different name or signature. For overriding the definition of the default test module's entry point:
  26. * [link boost_test.adv_scenarios.single_header_customizations.entry_point see here], for header-only usage variant,
  27. * [link boost_test.adv_scenarios.static_lib_customizations.entry_point see here], for static library usage variant,
  28. * [link boost_test.adv_scenarios.shared_lib_customizations.entry_point see here], for shared library usage variant.
  29. [endsect] [/section:entry_point_overview]