在测试用例中获取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_namep_parent_id,这是的ID测试套件。这两个属性都从test_unit继承,这是unit_testtest_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_suitep_name性质就像unit_test,所以你应该找到名字里。

+1

谢谢!我使用:'(boost :: unit_test :: framework :: get (prnt_id_t))。p_name',而'prnt_id_t'为:'boost :: unit_test :: framework :: current_test_case( ).p_parent_id;' – hudac