简体   繁体   English

GoogleTest run_all_tests找不到测试装置

[英]GoogleTest run_all_tests not finding test fixtures

I have a C++ project that is going to be made up of only google tests. 我有一个C ++项目,它将仅由Google测试组成。 This project references another project (the project it is testing). 该项目引用另一个项目(正在测试的项目)。 I have a include and source folder for the header and implementation files. 我有一个头文件和实现文件的include和source文件夹。 I am creating google test fixtures classes and split the header and implementation into the include and source folders. 我正在创建google测试装置类,并将标头和实现拆分为include和source文件夹。 I have a main.cpp that contains the following code: 我有一个main.cpp,其中包含以下代码:

//main.cpp
#include "../inc/zeroEstimatorTest.h"
#include "gtest/gtest.h"

int main(int argc, char **argv)
{
  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

The problem I am having is that the RUN_ALL_TESTS() call is not calling my google test fixture. 我遇到的问题是RUN_ALL_TESTS()调用未调用我的Google测试装置。 The test fixture is located in the implementation of the test class. 测试夹具位于测试类的实现中。 It looks like this: 看起来像这样:

//zeroEstimatorTest.cpp
class zeroEstimatorTest : public ::testing:Test
{
...
};

TEST_F(zeroEstimatorTest, zeroTest)
{
...
}

The project builds and runs but the output is the following: 该项目将生成并运行,但输出如下:

[0;32m[==========] [mRunning 0 tests from 0 test cases.
[0;32m[==========] [m0 tests from 0 test cases ran. (0 ms total)
[0;32m[  PASSED  ] [m0 tests.

I am currently using Eclipse (for the first time) and I am on a Linux 64 machine. 我目前正在使用Eclipse(第一次),并且在Linux 64计算机上。

Things I have done: 我所做的事情:

  • The zeroEstimatorTest class includes the "zeroEstimatorTest.h" at the top. zeroEstimatorTest类的顶部包含"zeroEstimatorTest.h"
  • The #include "gtest/gtest.h" is at the top of all three files (main.cpp, zeroEstimatorTest.h, and zeroEstimatorTest.cpp) #include "gtest/gtest.h"位于所有三个文件(main.cpp,zeroEstimatorTest.h和zeroEstimatorTest.cpp)的顶部。

Can anyone help? 有人可以帮忙吗?

Thank you very much! 非常感谢你!

问题是您没有设置测试过滤器名称,请尝试使用--gtest_filter =初始化google test,这可以使用main函数参数来完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM