【发布时间】:2018-11-27 23:11:49
【问题描述】:
Google Test C++ 单元测试框架提供了执行parameterised tests 的能力。要访问给定测试的参数,文档告诉我派生一个子类并调用GetParam():
class FooTest : public ::testing::TestWithParam<const char*> {
// You can implement all the usual fixture class members here.
// To access the test parameter, call GetParam() from class
// TestWithParam<T>.
};
我在文档或源代码中找不到比这更具体的内容(据我了解)。
我可以在哪里(或何时)致电GetParam()?我知道我可以在 TEST_P(...) { ... } 宏的主体中调用它,但是呢:
- 在
SetUp()方法中FooTest()? - 在
FooTest()的构造函数中? - 在
FooTest()的初始化列表中?
【问题讨论】:
标签: c++ googletest