I'm using BOOST TEST
and I wonder if there is a way to find out the test suite
from inside the test case
. I know that I can find test case
's name by:
boost::unit_test::framework::current_test_case().p_name
Is there a way to find out the suite name also?
My suites-cases structure is:
suite ---> case 1
______|--> case 2
______|--> case 3
Thanks
A
unit_test
has not onlyp_name
but alsop_parent_id
, which is the ID of the test suite. Both those properties are inherited fromtest_unit
, which is the common base class forunit_test
andtest_suite
.To get the suite from the ID, we can look at how
current_test_case
works:The
m_curr_test_case
member is atest_unit_id
, just likep_parent_id
. So, to get the test suite of the current test case, you can use this:Finally,
test_suite
has ap_name
property just likeunit_test
, so you should find the name there.