我试图先编写一个简单的程序来尝试让它工作,但是我没有任何机会调用“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
我有什么遗漏吗?
注意:我使用的是gtest v1.6.0-它是我公司的Red Hat RPM存储库中唯一可用的软件包。