Boost logo

Boost Users :

Subject: Re: [Boost-users] Test: Skip test from fixture
From: Raffi Enficiaud (raffi.enficiaud_at_[hidden])
Date: 2017-05-15 09:38:00


Le 09.05.17 à 11:26, Florian Lindner via Boost-users a écrit :
> Hello,
>
> given I have a test with a fixture. How can I skip that test from within the fixture?
>
> Thanks,
> Florian
>

Hi,

Not sure to understand what you mean: from the fixture itself, you want
to be able to skip the test, means that you have some logic inside your
fixture that determines if you need to run the test or not?

You may use the preconditions decorator:
http://www.boost.org/doc/libs/1_64_0/libs/test/doc/html/boost_test/tests_organization/enabling.html#boost_test.tests_organization.enabling.runtime_run_status

but currently this check is happening before the setup of the fixture is
called (with decorators, see
http://www.boost.org/doc/libs/1_64_0/libs/test/doc/html/boost_test/utf_reference/test_org_reference/decorator_fixture.html)
and this is not possible for the previous fixture API (eg.
http://www.boost.org/doc/libs/1_64_0/libs/test/doc/html/boost_test/tests_organization/test_suite.html#ref_BOOST_AUTO_TEST_SUITE)

For the API with inherited fixture classes, you can just set a boolean
flag inside the fixture class, and check for this flag inside the test
case body to early terminate. For the decorator API, you have to do it
in a different way as the decorator and the test body do not share state.

Raffi


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net