tjw*_*992 8 c++ automated-tests unit-testing googletest test-suite
我正在尝试编写一个执行测试套件级别的“设置”操作的测试套件。
我试图首先编写一个简单的程序来尝试使其运行,但是我没有运气来调用“ 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();
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到:
[==========] 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.
Run Code Online (Sandbox Code Playgroud)
由于某种原因SetUpTestSuite(),从未调用过。
我一直在阅读Google测试文档的“同一套件中的测试之间共享资源”部分,但无法弄清楚自己做错了什么。
我有什么想念的吗?
注意:我正在使用gtest v1.6.0-这是我公司Red Hat RPM存储库中可用的唯一软件包。
rve*_*erd 11
该文档似乎是错误的。这些方法应称为SetUpTestCase()和TearDownTestCase()。至少在Google Test 1.8.0中。
| 归档时间: |
|
| 查看次数: |
1212 次 |
| 最近记录: |