test
test copied to clipboard
Data driven test cases: customizing test names and decorators
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.
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.
Maybe it would be easier to change a data test description?