57 lines
2.9 KiB
Plaintext
57 lines
2.9 KiB
Plaintext
[/
|
|
/ Copyright (c) 2003 Boost.Test contributors
|
|
/
|
|
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
/]
|
|
|
|
[section:enabling Enabling or disabling test unit execution]
|
|
|
|
The __UTF__ provides a way for enabling or disabling a test unit execution. If a test case is disabled, it will not be
|
|
run by the test runner. If a test suite is disabled, its status is inherited by the test units under its subtree, unless
|
|
otherwise specified.
|
|
|
|
The run status can be overridden by the command line parameters: by providing the appropriate arguments to the command
|
|
line, a disabled test may still be executed. The [link boost_test.runtime_config.test_unit_filtering test unit
|
|
filtering] section covers this feature in details.
|
|
|
|
[h3 Unconditional run status]
|
|
Decorator __decorator_disabled__ indicates that the test unit's __default_run_status__ is ['false]. This means that that
|
|
test cases inside this test unit will not be run by default, unless otherwise specified. Decorator __decorator_enabled__
|
|
indicates that the test unit's default run status is ['true]. This means that that test cases inside this test unit will
|
|
be run by default, unless otherwise specified.
|
|
|
|
[bt_example decorator_05..decorators enabled and disabled..run-fail]
|
|
|
|
Syntactically, it is possible to apply both decorators `enabled` and `disabled` to the same test unit. This is reported
|
|
as set-up error when the test program is run.
|
|
|
|
[h3 Compilation-time run status]
|
|
|
|
Decorator __decorator_enable_if__ indicates that the test unit's __default_run_status__ is either ['true] or ['false],
|
|
depending on the value of `Condition`. This means that that test cases inside this test unit will or will not be run by
|
|
default.
|
|
|
|
|
|
[bt_example decorator_06..decorator enable_if..run-fail]
|
|
|
|
Decorator `enable_if<true>()` is equivalent to decorator `enabled()`. Similarly, `enable_if<false>()` is equivalent to
|
|
decorator `disabled()`.
|
|
|
|
[/-----------------------------------------------------------------]
|
|
[h3 Runtime run status]
|
|
|
|
Decorator __decorator_precondition__ associates a ['predicate] with a test unit. Before the test unit is executed, the
|
|
predicate is evaluated with the test unit's ID passed as the argument. If it evaluates to `false`, execution of the test
|
|
unit is skipped. Skipping the test suite means skipping the execution of every test unit inside.
|
|
|
|
[bt_example decorator_08..decorator precondition..run-fail]
|
|
|
|
In the example above, the user defined a custom predicate `if_either` that evaluates to `true` if at least one of the two
|
|
specified tests passed. (It assumes that the tests are registered in the specific order.) Test case `test3` has a
|
|
precondition that at either `test1` or `test2` passed. The precondition is satisfied, therefore `test3` is run (and
|
|
fails). Test case `test4` has a precondition that either `test2` or `test3` passed. Since they both failed, the
|
|
precondition is not satisfied, therefore `test4` is skipped.
|
|
|
|
[endsect]
|