在Google Test参数化测试用例(`TEST_P`)中访问测试信息

Яois

创建常规TEST(或TEST_F)时,我可以访问存储在中的测试用例信息test_info_,例如:

TEST_F(MyTestSuite, TestCaseOne) 
{
  // ... 
  test_info_->name(); // will return "TestCaseOne"
}

当我使用参数化(TEST_P)变体时,我想访问此类信息,该变体允许我定义基于夹具的测试。

从内幕看,我发现它的TEST_P工作原理与她的表亲TEST完全不同TEST_F,因为它通过调用方法注册了新的测试用例::testing::UnitTest::GetInstance()->parameterized_test_registry().GetTestCasePatternHolder<test_case_name>(#test_case_name, __FILE__, __LINE__)->AddTestPattern(...)我知道,继承自该类的类TestWithParam将运行所有已注册TEST_P的测试用例。

有没有一种方法(运行时或编译时)访问a的名称(字符串)TEST_P

弗雷泽

TestInfo实例实际上有一个吸气剂文档中

为了获得TestInfo当前运行的测试,调用对象current_test_info()上的UnitTest单个对象:

// Gets information about the currently running test.
// Do NOT delete the returned object - it's managed by the UnitTest class.
const ::testing::TestInfo* const test_info =
  ::testing::UnitTest::GetInstance()->current_test_info();
printf("We are in test %s of test case %s.\n",
       test_info->name(), test_info->test_case_name());

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在参数化的Google Test中加载测试序列文件

Google Test测试名称混乱

如何在Google Test(gtest)中使用夹具成员值运行参数化测试?

如何在Google Code Jam中的C ++代码中输入测试用例

无序逃生-Google Foobar 2020未通过测试用例

Google Foobar 问题 - Python 测试用例失败

Py.test:来自类的参数测试用例

如何在Google Test TearDown()中检查测试是否失败?

如何在Eclipse中的py.test中运行特定的参数测试用例

使用Google Test测试Map <int,vector>

使用Google Test API for C ++通过参数化单元测试来测试私有方法的可能方法是什么?

您如何选择要运行的特定Google Mock测试用例/单元测试?

在 jpm test 命令中打印测试用例名称

在JIRA-Xray中参数化测试用例

如何在单元测试框架Google Test中结合测试过滤器?

GTest,仅参数化测试用例

访问JUnit测试用例中的列表

访问“it”“测试用例”中的夹具数据

无法定义硒的测试用例以在Google上查找Fox体育

Google Foobar Challenge世界末日加油赛未通过隐藏测试用例

Google Foobar挑战赛,一个测试用例失败

Google Foobar escape-pods 测试用例 N. 4 失败

Microsoft Test Manager中特定测试套件的测试用例状态的批量更改

如何使用Google Test测试C的静态功能

如何使用Google Test测试实现接口的不同类/结构?

如何在Xcode 6.1.1中使用Google Test运行本地C ++单元测试

如何在VS Code中运行测试和调试Google Test项目?

如何使用Google Test在main()函数中的特定位置调用特定的测试函数?

无法在Google Pay TEST环境中添加测试卡和订单总数