作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试编写一个测试套件来执行测试套件级别的“设置”操作。
我试图首先编写一个简单的程序来尝试让它工作,但我没有运气调用“SetUpTestSuite”方法。
#include <gtest/gtest.h>
#include <iostream>
class MyTest : public ::testing::Test
{
protected:
static void SetUpTestSuite() {
std::cerr << "TestSuiteSetup" << std::endl;
}
static void TearDownTestSuite() {
}
};
TEST_F(MyTest, Case1) {
std::cerr << "TESTING" << std::endl;
}
int main(int argc, char* argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
当我运行它时,我得到:
[==========] Running 1 tests from 1 test cases.
[----------] Global test environment set-up.
[----------] 1 test from MyTest
[ RUN ] MyTest.Case1
TESTING
[ OK ] MyTest.Case1 (0 ms)
[----------] 1 test from MyTest (0 ms total)
[----------] Global test environment tear-down
[==========] 1 tests from 1 test cases ran. (0 ms total)
[ PASSED ] 1 tests.
由于某些原因,SetUpTestSuite()
从未被调用。
我一直在阅读 Sharing Resources Between Tests in the Same Suite Google 测试文档的一部分,但我不知道我做错了什么。
有什么我想念的吗?
注意:我使用的是 gtest v1.6.0 - 它是我公司 Red Hat RPM 存储库中唯一可用的软件包。
最佳答案
文档似乎有误。这些方法应称为 SetUpTestCase()
和 TearDownTestCase()
。至少在 Google Test 1.8.0 中是这样。
关于c++ - Google 测试 - 使用 "SetUpTestSuite"似乎不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54468799/
我正在尝试编写一个测试套件来执行测试套件级别的“设置”操作。 我试图首先编写一个简单的程序来尝试让它工作,但我没有运气调用“SetUpTestSuite”方法。 #include #include
我是一名优秀的程序员,十分优秀!