In Boost.Test, how can I obtain the name of the current auto test case?
Example:
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(MyTest)
{
std::cerr << "Starting " << test_name << std::endl;
// lots of code here
std::cerr << "Ending " << test_name << std::endl;
}
In the example, I want the variable test_name to contain “MyTest”.
There is an undocumented* function that may be called for that purpose. The following line will flush the name of the current test to
cerr:Note however that using this API does not flush the parameters in case of parametrized tests.
You might also be interested in the test checkpoints** (which seems to be what you want to do.)
EDIT
* The
current_test_case()function is now documented, see the official Boost documentation.**
BOOST_TEST_CHECKPOINTwas previously calledBOOST_CHECKPOINT. See the Boost changelog (1.35.0).