Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using the testcase name in output file names

Tags:

c++

boost-test

I use boost::test to run integration tests on a class that creates directories and files. I would like these files to be named test-case specific so if I run into trouble I can easily find which test case left its directories/files around.

So I would like to use the test case name in the constructor of the fixture that I'm using, as demonstrated below. Is this possible at all, and how? I searched the boost::test manual but could not find this information.

e.g.

struct foo_fixture
{
    foo_fixture() 
    { 
        std::string case_dependent_name( BOOST_TEST_CASE_NAME ); 
        create_directory( case_dependent_name );
    }
};

BOOST_FIXTURE_TEST_CASE ( foo_case_one, foo_fixture )
{
   ...
}
BOOST_FIXTURE_TEST_CASE ( foo_case_two, foo_fixture )
{
   ...
}
like image 558
andreas buykx Avatar asked Nov 11 '10 09:11

andreas buykx


1 Answers

I found this, and it works:

boost user group discussion

Essentially, you use the string member variable found on the test_unit instance:

boost::unit_test::framework::current_test_case().p_name
like image 194
Dan B Avatar answered Sep 26 '22 02:09

Dan B