在测试用例中获取BOOST TEST测试套件名称
问题描述:
我正在使用BOOST TEST
,我想知道是否有办法从test case
中找出test suite
。我知道,我可以找到test case
的名字:在测试用例中获取BOOST TEST测试套件名称
boost::unit_test::framework::current_test_case().p_name
有没有办法找出套件名称也?
我的套房,案件结构为:
suite ---> case 1
______|--> case 2
______|--> case 3
感谢
答
一个unit_test
不仅p_name
也p_parent_id
,这是的ID测试套件。这两个属性都从test_unit
继承,这是unit_test
和test_suite
的通用基类。
查看该ID的套件,我们可以看看如何current_test_case
作品:
test_case const&
current_test_case()
{
return get<test_case>(s_frk_impl().m_curr_test_case);
}
的m_curr_test_case
件是test_unit_id
,就像p_parent_id
。因此,要获得当前测试用例的测试套件,你可以使用这个:
framework::get<test_suite>(current_test_case().p_parent_id)
最后,test_suite
有p_name
性质就像unit_test
,所以你应该找到名字里。
谢谢!我使用:'(boost :: unit_test :: framework :: get(prnt_id_t))。p_name',而'prnt_id_t'为:'boost :: unit_test :: framework :: current_test_case( ).p_parent_id;' –
hudac