Re: [boost] [test] Automatic registration of tests created with BOOST_PARAM_TEST_CASE

Boost.Test do not support this setup out of the box
It seems to me that there's no unit testing framework for C++ that would support that (please correct me if I'm wrong).
Your best shot probably is to try ot do this in global fixture. Would this be a good solution if I had many tests with lots of data sets?
You can implement your own generator. Could you point me to example on how to do that?
Jan

Jan Stolarek <fremenzone <at> poczta.onet.pl> writes:
Boost.Test does support it. It's just require some extra leg work from you.
These rather belong to the advanced usage cases. These docs are only in plans.
This is not a good idea. I found it in documentation for Boost 1.34 :
http://www.boost.org/doc/libs/1_34_1/libs/test/doc/tests/parameterized_test_... This is not what expected to do. This is my own internal unit test.
Your best shot probably is to try to do this in global fixture. Would this be a good solution if I had many tests with lots of data sets?
Should not matter, but I just tested and global fixture is invoked too late.
You can implement your own generator. Could you point me to example on how to do that?
You can look into the code. There are at least two implemented there.
Here an example that works fine: #define BOOST_TEST_MAIN #include <boost/test/unit_test.hpp> #include <boost/test/parameterized_test.hpp> using namespace boost::unit_test; // STL #include <vector> #include <string> //____________________________________________________________________________// // this free function is invoked with all parameters specified in a list void check_string( std::string const& s ) { // reports 'error in "check_string": test s.substr( 0, 3 ) == "hdr" failed [actual_value != hdr]' BOOST_CHECK_EQUAL( s.substr( 0, 3 ), "hdr" ); } //____________________________________________________________________________// static struct Setup { Setup() { framework::master_test_suite().p_name.value = "Automatically registered param test case"; // parameters have no requirements to stay alive beyond the next statement std::string const params[] = { "hdr1 ", "hdr2", "3 " }; framework::master_test_suite().add( BOOST_PARAM_TEST_CASE( &check_string, (std::string const*)params, params+3 ) ); } } _s_setup; //____________________________________________________________________________//
participants (2)
-
Gennadiy Rozental
-
Jan Stolarek