3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Test module's entry point</title>
5 <link rel="stylesheet" href="../../boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../index.html" title="Boost.Test">
8 <link rel="up" href="../adv_scenarios.html" title="Advanced Usage Scenarios">
9 <link rel="prev" href="build_utf.html" title="Building the Unit Test Framework">
10 <link rel="next" href="test_module_init_overview.html" title="Test module's initialization">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="build_utf.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../adv_scenarios.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="test_module_init_overview.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h3 class="title">
27 <a name="boost_test.adv_scenarios.entry_point_overview"></a><a class="link" href="entry_point_overview.html" title="Test module's entry point">Test module's
29 </h3></div></div></div>
31 Typically, every C++ program contains exactly one definition of function
32 <code class="computeroutput"><span class="identifier">main</span></code>: the program's <span class="emphasis"><em>entry
33 point</em></span>. When using the <span class="emphasis"><em>Unit Test Framework</em></span>
34 you do not have to define one. Function <code class="computeroutput"><span class="identifier">main</span></code>
35 will be generated for you by the framework. The only thing you are required
36 to do in case your program consists of more than one translation unit (<code class="computeroutput"><span class="identifier">cpp</span></code> file) is to indicate to the framework
37 in which of the files it is supposed to generate function <code class="computeroutput"><span class="identifier">main</span></code>.
38 You do it by defining macro <a class="link" href="../utf_reference/link_references/link_boost_test_module_macro.html" title="BOOST_TEST_MODULE"><code class="computeroutput"><span class="identifier">BOOST_TEST_MODULE</span></code></a> before the inclusion
39 of any of the framework files. The value of this macro is used as a name
40 of the <a class="link" href="../section_glossary.html#ref_test_module">test module</a> as well as the
41 <a class="link" href="../tests_organization/test_tree/master_test_suite.html" title="Master test suite">master
45 The reason for defining function <code class="computeroutput"><span class="identifier">main</span></code>
48 <div class="orderedlist"><ol class="orderedlist" type="1">
50 This allows the <span class="emphasis"><em>Unit Test Framework</em></span> to perform some
51 custom <a class="link" href="test_module_init_overview.html" title="Test module's initialization"><span class="emphasis"><em>test
52 module initialization</em></span></a>.
55 This prevents you defining <code class="computeroutput"><span class="identifier">main</span></code>,
56 and accidentally forgetting to run all the test (in which case running
57 the program would incorrectly indicate a clean run).
61 By default, the test module's entry point is defined with signature:
63 <pre class="programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">argv</span><span class="special">[]);</span>
66 It calls <a class="link" href="test_module_init_overview.html" title="Test module's initialization"><span class="emphasis"><em>test
67 module initialization</em></span></a> function, then calls the <a class="link" href="test_module_runner_overview.html" title="Test module runner"><span class="emphasis"><em>test
68 module runner</em></span></a> and forwards its return value to environment.
71 The default entry point is sufficient in most of the cases. Occasionally,
72 a need may arise to declare an entry point with a different name or signature.
73 For overriding the definition of the default test module's entry point:
75 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
77 <a class="link" href="single_header_customizations/entry_point.html" title="Customizing the module's entry point">see
78 here</a>, for header-only usage variant,
81 <a class="link" href="static_lib_customizations/entry_point.html" title="Customizing the module's entry point">see
82 here</a>, for static library usage variant,
85 <a class="link" href="shared_lib_customizations/entry_point.html" title="Customizing the module's entry point">see
86 here</a>, for shared library usage variant.
90 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
91 <td align="left"></td>
92 <td align="right"><div class="copyright-footer">Copyright © 2001-2019 Boost.Test
94 Distributed under the Boost Software License, Version 1.0. (See accompanying
95 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
100 <div class="spirit-nav">
101 <a accesskey="p" href="build_utf.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../adv_scenarios.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="test_module_init_overview.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>