test icon indicating copy to clipboard operation
test copied to clipboard

Data driven test cases: customizing test names and decorators

Open anarthal opened this issue 4 years ago • 2 comments

Hi,

Is it possible to customize the test names generated by the data-driven test case macros (BOOST_DATA_TEST_CASE)? In Google Test, you can do:

INSTANTIATE_TEST_SUITE_P(InstantiationName, TestSuiteName, Values(
    /* dataset here */
), test_name_generator);

Where test_name_generator is a function that takes as argument a wrapped sample and returns a string with the name the test should have. That replaces the "_0", "_1"... generated by default. So your test names would be something like:

  • InstantiationName/TestSuiteName/Name1
  • InstantiationName/TestSuiteName/Name2

Assuming test_name_generator would return Name1 and Name2 for the two samples of the dataset.

Is there something similar available in Boost.Test? If there is not, what would be the equivalent using manual test registration? All these tests do use fixtures. I would also need to apply different labels depending on the sample.

Many thanks.

anarthal avatar Jun 21 '20 19:06 anarthal

I would like this, too, but the approach of having the names be made at runtime might be difficult! I'd be okay with requiring that the name can be generated by a constexpr, too.

eyal0 avatar Feb 10 '21 19:02 eyal0

Maybe it would be easier to change a data test description?

pasniak avatar Mar 17 '21 20:03 pasniak