c++boostboost-unit-test-framework

boost unit test filter when using a fixture


I need to specify a specific unit test to run. Of course, I looked at Stack Overflow Answers after I looked at the documentation, but neither used a fixture.

How do I specify a test case to run if I have:

BOOST_AUTO_TEST_SUITE(mysuite)

struct Fixture
{
    Fixture()
    {
        BOOST_TEST_MESSAGE("Setup");
    }

    ~Fixture()
    {
        BOOST_TEST_MESSAGE("Teardown");
    }
};

BOOST_FIXTURE_TEST_CASE(add_remove, Fixture)
{
}

BOOST_AUTO_TEST_SUITE_END()

If I pass --run_test=add_remove, the process returns with a message Test setup error: no test cases matching filter or all test cases were disabled.

I've looked at: http://www.boost.org/doc/libs/1_64_0/libs/test/doc/html/boost_test/runtime_config/test_unit_filtering.html

Is it possible to run only subsets of a Boost unit test module?

How to set which Boost unit test to run


Solution

  • When you're using the path to the test case as the argument to --run_test, it must also include the name of the suite. In your case, pass --run_test=mysuite/add_remove. This is described in the documentation (look at the table in that section).

    Live demo