Boost Unit Test: How to run only the enabled tests of a test suite?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Boost Unit Test: How to run only the enabled tests of a test suite?

Boost - Users mailing list
Hey,

I'm looking for a way to only run the enabled unit tests of a tests suite.

I have the following test suite:
#define BOOST_TEST_MODULE decorator_predicate
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;

BOOST_AUTO_TEST_SUITE(test_suite_1)

BOOST_AUTO_TEST_CASE(bare_test)
{
  BOOST_TEST(true);
}

BOOST_AUTO_TEST_CASE(enabled_test,
  * utf::enabled())
{
  BOOST_TEST(true);
}

BOOST_AUTO_TEST_CASE(disabled_test,
  * utf::disabled())
{
  BOOST_TEST(false);
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE(test_suite_2)

BOOST_AUTO_TEST_CASE(bare_test)
{
  BOOST_TEST(true);
}

BOOST_AUTO_TEST_CASE(enabled_test,
  * utf::enabled())
{
  BOOST_TEST(true);
}

BOOST_AUTO_TEST_CASE(disabled_test,
  * utf::disabled())
{
  BOOST_TEST(false);
}

BOOST_AUTO_TEST_SUITE_END()
Compilation and running:
# Compile the test
g++ predicate.cpp -o predicate

# List all tests
./predicate --list_content
test_suite_1*
    bare_test*
    enabled_test*
    disabled_test 
test_suite_2*
    bare_test*
    enabled_test*
    disabled_test 

# Run the tests that are enabled by default
./predicate
Running 4 test cases...

*** No errors detected

# Here, I would like to only run the enabled tests of test_suite_1.
# Instead, all tests are run. Including the disabled.
./predicate -t test_suite_1
Running 3 test cases...
predicate.cpp(21): error: in "test_suite_1/disabled_test": check false has failed

*** 1 failure is detected in the test module "decorator_predicate"

How can I only run the enabled tests of tst_suite1?

Only bare_test and enabled_test should be run.

Thanks!

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost Unit Test: How to run only the enabled tests of a test suite?

Boost - Users mailing list
Le 27.10.17 à 03:03, Maarten Anonymous via Boost-users a écrit :

> Hey,
>
> I'm looking for a way to only run the enabled unit tests of a tests suite.
>
> I have the following test suite:
>
> |#defineBOOST_TEST_MODULE decorator_predicate
> #include<boost/test/included/unit_test.hpp>namespaceutf
> =boost::unit_test;BOOST_AUTO_TEST_SUITE(test_suite_1)BOOST_AUTO_TEST_CASE(bare_test){BOOST_TEST(true);}BOOST_AUTO_TEST_CASE(enabled_test,*utf::enabled()){BOOST_TEST(true);}BOOST_AUTO_TEST_CASE(disabled_test,*utf::disabled()){BOOST_TEST(false);}BOOST_AUTO_TEST_SUITE_END()BOOST_AUTO_TEST_SUITE(test_suite_2)BOOST_AUTO_TEST_CASE(bare_test){BOOST_TEST(true);}BOOST_AUTO_TEST_CASE(enabled_test,*utf::enabled()){BOOST_TEST(true);}BOOST_AUTO_TEST_CASE(disabled_test,*utf::disabled()){BOOST_TEST(false);}BOOST_AUTO_TEST_SUITE_END()|
>
> Compilation and running:
>
> |# Compile the testg++predicate.cpp -o predicate # List all
> tests./predicate --list_content
> test_suite_1*bare_test*enabled_test*disabled_test
> test_suite_2*bare_test*enabled_test*disabled_test # Run the tests that
> are enabled by default./predicate Running4test cases...***Noerrors
> detected # Here, I would like to only run the enabled tests of
> test_suite_1.# Instead, all tests are run. Including the
> disabled../predicate -t test_suite_1 Running3test
> cases...predicate.cpp(21):error:in"test_suite_1/disabled_test":check
> falsehas failed ***1failure isdetected inthe test
> module"decorator_predicate"|
>
>
> How can I only run the enabled tests of tst_suite1?
>
> Only bare_test and enabled_test should be run.
>
> Thanks!
>

Hi,
As soon as you indicate the tests to run on the command line, the UTF
disables all the tests except the ones falling into the filtered set of
tests.

There is no way to select on the command line filter the tests that are
disabled/enabled. You would find a way to achieve what you want with
preconditions (such as checking some command line switch) or even
better, labels.

Raffi


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users