得到测试箱内BOOST试验测试套件名称 [英] Get BOOST TEST test suite name inside a test case

查看:201
本文介绍了得到测试箱内BOOST试验测试套件名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 BOOST试验,我不知道是否有到测试套件从找到出路在试验箱内。我知道我可以找到测试用例姓名:

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 ::框架:: current_test_case()。p_name

有没有办法找出套件名称也?

Is there a way to find out the suite name also?

我的套房,案件结构是:

My suites-cases structure is:

套件--->案例1

______ | - >案例2

______ | - >案例3

感谢

推荐答案

A unit_test 不仅 p_name ,但还 p_parent_id ,这是测试套件的ID。这两个属性是从 test_unit 继承,这是的公共基类unit_test test_suite

A unit_test has not only p_name but also p_parent_id, which is the ID of the test suite. Both those properties are inherited from test_unit, which is the common base class for unit_test and test_suite.

要获得该ID的套件,我们可以看看如何 current_test_case

To get the suite from the ID, we can look at how current_test_case works:

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 。因此,要获得当前测试用例的测试套件,你可以使用这样的:

The m_curr_test_case member is a test_unit_id, just like p_parent_id. So, to get the test suite of the current test case, you can use this:

framework::get<test_suite>(current_test_case().p_parent_id)

最后, test_suite 有一个 p_name 属性就像 unit_test ,所以你应该在那里找到的名字。

Finally, test_suite has a p_name property just like unit_test, so you should find the name there.

这篇关于得到测试箱内BOOST试验测试套件名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆