]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/test/doc/test_organization/testorg_reference.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / test / doc / test_organization / testorg_reference.qbk
CommitLineData
7c673cae
FG
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
8[section:test_org_reference Tests declaration and organization]
9
10
11
12
13[/ Test cases ###############################################################################################]
14[section:test_org_boost_test_case `BOOST_TEST_CASE`]
15Creates a test case for manual registration. The registration in the test tree should be performed manually.
16
17See [link ref_BOOST_TEST_CASE here] for more details.
18[endsect] [/section:test_org_boost_test_case]
19
20[section:test_org_boost_auto_test_case `BOOST_AUTO_TEST_CASE`]
21Declares and registers automatically a test case.
22
23See [link ref_BOOST_AUTO_TEST_CASE here] for more details.
24[endsect] [/section:test_org_boost_auto_test_case]
25
26
27[section:test_org_boost_test_case_auto_template `BOOST_AUTO_TEST_CASE_TEMPLATE`]
28Declares and registers automatically a typed test case.
29
30See [link ref_BOOST_AUTO_TEST_CASE_TEMPLATE here] for more details.
31[endsect] [/section:test_org_boost_test_case_auto_template]
32
33
34[section:test_org_boost_test_case_template `BOOST_TEST_CASE_TEMPLATE`]
35Creates a typed test case. The test case should have been declared with the macro __BOOST_TEST_CASE_TEMPLATE_FUNCTION__.
36The registration in the test tree should be performed manually.
37
38See [link ref_BOOST_TEST_CASE_TEMPLATE here] for more details.
39[endsect] [/section:test_org_boost_test_case_template]
40
41[section:test_org_boost_test_case_template_function `BOOST_TEST_CASE_TEMPLATE_FUNCTION`]
42Declares a typed test case. The registration in the test tree should be performed manually, using the macro
43__BOOST_TEST_CASE_TEMPLATE__.
44
45See [link ref_BOOST_TEST_CASE_TEMPLATE here] for more details.
46[endsect] [/section:test_org_boost_test_case_template_function]
47
48[section:test_org_boost_test_case_parameter `BOOST_PARAM_TEST_CASE`]
49Declares and registers automatically a test case with one parameter.
50
51See [link boost_test.tests_organization.test_cases.param_test here] for more details.
52[endsect] [/section:test_org_boost_test_case_parameter]
53
54
55[section:test_org_boost_test_dataset `BOOST_DATA_TEST_CASE`]
56Declares and registers a data-driven test case, using a particular dataset.
57
58Several forms of the macro are available.
59
60
61``
62BOOST_DATA_TEST_CASE(test_case_name, dataset)
63{
64 BOOST_TEST(sample != 0);
65}
66``
67should be used for datasets with arity 1. In the body of the test case, the samples of the dataset are taken by the variable `sample`.
68
69``
70BOOST_DATA_TEST_CASE(test_case_name, dataset, var1)
71{
72 BOOST_TEST(var1 != 0);
73}
74``
75same as the first form, but the samples are taken by the variable `var1` instead of the variable `sample`
76
77
78``
79BOOST_DATA_TEST_CASE(test_case_name, dataset, var1, var2..., varN)
80{
81 BOOST_TEST(var1 != 0);
82 //...
83 BOOST_TEST(varN != 0);
84}
85``
86
87same as the second form, but for dataset of arity `N`.
88
89For compilers *lacking the variadic template* support, the maximal arity (the maximal value of `N`) is controlled by the macro
90`BOOST_TEST_DATASET_MAX_ARITY` which is set to `10` by default. If you need a greater value, define `BOOST_TEST_DATASET_MAX_ARITY`
91to the desired value *before* including the __UTF__ headers.
92
93See [link boost_test.tests_organization.test_cases.test_case_generation.datasets_auto_registration here] for more details.
94
95[endsect] [/section:test_org_boost_test_dataset]
96
97[section:test_org_boost_test_dataset_fixture `BOOST_DATA_TEST_CASE_F`]
98Declares and registers a data-driven test case, using a particular dataset and a fixture. This is basically the same as
99__BOOST_DATA_TEST_CASE__ with fixture support added.
100
101``
102struct my_fixture {
103 my_fixture() : some_string("environment X") {
104 }
105 std::string some_string;
106};
107
108BOOST_DATA_TEST_CASE_F(my_fixture, test_case_name, dataset, var1, var2..., varN)
109{
110 BOOST_TEST(var1 != 0);
111 //...
112 BOOST_TEST(varN != 0);
113}
114``
115
116The fixture should implement the appropriate [link boost_test.tests_organization.fixtures.models interface].
117As any fixture, it is possible to have test assertions in the fixture class.
118
119See [link boost_test.tests_organization.fixtures.case here] for more details on fixtures and
120[link boost_test.tests_organization.test_cases.test_case_generation.datasets_auto_registration here] for more details on datasets
121declaration.
122
123[endsect] [/section:test_org_boost_test_dataset_fixture]
124
125[/ Test suites ###############################################################################################]
126[section:test_org_boost_test_suite `BOOST_TEST_SUITE`]
127Creates a test suite. The created test suite should be added to the test tree manually.
128
129See [link ref_BOOST_TEST_SUITE here] for more details.
130[endsect] [/section:test_org_boost_test_suite]
131
132[section:test_org_boost_auto_test_suite `BOOST_AUTO_TEST_SUITE`]
133Indicates the beginning of a test suite. Test suites can be nested.
134
135See [link ref_BOOST_AUTO_TEST_SUITE here] for more details.
136[endsect] [/section:test_org_boost_auto_test_suite]
137
138[section:test_org_boost_auto_test_suite_end `BOOST_AUTO_TEST_SUITE_END`]
139Indicates the end of a test suite. Test suites can be nested. This macro should appear as many times as there is a
140__BOOST_AUTO_TEST_SUITE__.
141
142See [link ref_BOOST_AUTO_TEST_SUITE here] for more details.
143[endsect] [/section:test_org_boost_auto_test_suite_end]
144
145
146
147[/ Fixtures ###############################################################################################]
148[/-----------------------------------------------------------------]
149[section:test_org_boost_test_case_fixture `BOOST_FIXTURE_TEST_CASE`]
150Declares and registers a test case that uses a fixture. The class implementing the fixture should have the appropriate
151[link boost_test.tests_organization.fixtures.models interface].
152As any fixture, it is possible to have test assertions in the fixture class.
153
154See [link boost_test.tests_organization.fixtures.case here] for more details.
155[endsect] [/section:test_org_boost_test_case_fixture]
156
157[/-----------------------------------------------------------------]
158[section:test_org_boost_test_suite_fixture `BOOST_FIXTURE_TEST_SUITE`]
159Declares and registers a fixture used by all test cases under a test suite.
160Each test case in the subtree of the test suite uses the fixture.
161The class implementing the fixture should have the appropriate [link boost_test.tests_organization.fixtures.models interface].
162As any fixture, it is possible to have test assertions in the fixture class.
163
164See [link boost_test.tests_organization.fixtures.case here] for more details.
165[endsect] [/section:test_org_boost_test_case_fixture]
166
167[/-----------------------------------------------------------------]
168[section:test_org_boost_global_fixture `BOOST_GLOBAL_FIXTURE`]
169Declares and registers a global fixture. The global fixture is called before any of the test case in the test tree is executed.
170The class implementing the fixture should have the appropriate [link boost_test.tests_organization.fixtures.models interface].
171As any fixture, it is possible to have test assertions in the global fixture.
172
173See [link boost_test.tests_organization.fixtures.global here] for more details.
174[endsect] [/section:test_org_boost_test_case_fixture]
175
176
177
178
179
180[/ Decorators ##############################################################################################]
181[section:test_org_boost_test_decorator `BOOST_TEST_DECORATOR`]
182Defines ['decorators] for a test unit.
183
184See [link boost_test.tests_organization.decorators here] for more details.
185[endsect] [/section:test_org_boost_test_decorator]
186
187
188[/-----------------------------------------------------------------]
189[section:decorator_depends_on depends_on (decorator)]
190
191``
192depends_on(const_string dependent_test_name);
193``
194
195Indicates a dependency from the decorated test unit (the child) to the designed test unit `dependent_test_name` (the parent).
196See [link boost_test.tests_organization.tests_dependencies here] for more details.
197
198[endsect] [/ section decorator_depends_on]
199
200
201
202[/-----------------------------------------------------------------]
203[section:decorator_description description (decorator)]
204
205``
206description(const_string message);
207``
208
209Attaches an arbitrary string to the test unit.
210See [link boost_test.tests_organization.semantic here] for more details.
211
212[endsect] [/ decorator description]
213
214
215
216
217[/-----------------------------------------------------------------]
218[section:decorator_enabled enabled / disabled (decorator)]
219
220``
221enabled();
222disabled();
223``
224
225Sets the test unit's __default_run_status__ to ['true] or ['false].
226See [link boost_test.tests_organization.enabling here] for more details.
227
228[endsect] [/ section:decorator_enabled]
229
230
231[/-----------------------------------------------------------------]
232[section:decorator_enable_if enable_if (decorator)]
233
234``
235template <bool Condition> enable_if();
236``
237Sets the test unit's __default_run_status__ to ['true] or ['false], depending on a compilation-time
238constant.
239See [link boost_test.tests_organization.enabling here] for more details.
240
241
242[endsect] [/ section enable_if]
243
244
245[/-----------------------------------------------------------------]
246[section:decorator_fixture fixture (decorator)]
247
248``
249fixture(const boost::function<void()>& setup, const boost::function<void()>& teardown = {});
250
251template <typename Fx>
252 fixture<Fx>();
253
254template <typename Fx, typename Arg>
255 fixture<Fx>(const Arg& arg);
256``
257
258Decorator `fixture` specifies a pair of functions (like `set_up` and `tear_down`) to be called before and after the
259corresponding test unit. At the suite level the `set_up` function is called once -- before the suite execution starts
260and `tear_down` function is called once -- after the suite execution ends. It comes in three forms. First expects two
261functions for set-up and tear-down (the second one can be skipped). The second expects a `DefaultConstructible` class.
262Its default constructor will be used as set-up function and its destructor as a tear-down function. Third requires a
263class with one-argument public constructor. Argument `arg` is forwarded to the constructor and this is the set-up
264function, its destructor is the tear-down function. There is no way to get access to the members of these fixtures from
265within the test case or test suite.
266
267[bt_example decorator_12..decorator fixture..run]
268
269For other ways of using fixtures, see [link boost_test.tests_organization.fixtures here].
270
271[endsect] [/ section fixture]
272
273
274
275[/-----------------------------------------------------------------]
276[section:decorator_label label (decorator)]
277
278``
279label(const_string label_name);
280``
281
282Associates a test unit with label `label_name`. It is possible to associate more than one label with a test unit.
283See [link boost_test.tests_organization.tests_grouping here] for more details.
284
285[endsect] [/ section label]
286
287
288[/-----------------------------------------------------------------]
289[section:decorator_precondition precondition (decorator)]
290
291[def __class_assertion_result__ [classref boost::test_tools::assertion_result test_tools::assertion_result]]
292``
293typedef boost::function<__class_assertion_result__ (test_unit_id)> predicate_t;
294
295precondition(predicate_t predicate);
296``
297
298Associates a ['predicate] with a test unit that will determine its __default_run_status__ at run-time.
299See [link boost_test.tests_organization.enabling here] for more details.
300
301[endsect] [/ section decorator_precondition]
302[endsect] [/reference test organization]