boostorg / test

The reference C++ unit testing framework (TDD, xUnit, C++03/11/14/17)
http://boost.org/libs/test
Boost Software License 1.0
182 stars 141 forks source link

Unexpected behavior with `--run_test` #404

Closed lballabio closed 10 months ago

lballabio commented 10 months ago

With the following file:

#define BOOST_TEST_MODULE My Test
#include <boost/test/included/unit_test.hpp>

namespace utf = boost::unit_test;

BOOST_AUTO_TEST_SUITE(first_suite)

BOOST_AUTO_TEST_CASE(first_test)
{
  BOOST_TEST(1 == 1);
}

BOOST_AUTO_TEST_CASE(second_test, *utf::disabled())
{
  BOOST_TEST(2 == 0);
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE(second_suite)

BOOST_AUTO_TEST_CASE(first_test)
{
  BOOST_TEST(4 == 4);
}

BOOST_AUTO_TEST_SUITE_END()

Running the test program without arguments doesn't run the disabled test, but running it with --run_test=first_suite does. Is this the wanted behavior? I can see how this behavior could be defended if one were to use --run_test=first_suite/*, but when passing just the name of the suite it looks counterintuitive.

And if this is indeed intended, is there a way to tell the program "run this suite only and keep the disabled tests disabled"? Thanks!

raffienficiaud commented 10 months ago

Hi Luigi,

That behaviour is intentional (more on this in this section):

This does not directly answer your question, but the test filtering is actually quite flexible.

lballabio commented 10 months ago

Thanks!