这是我第一次在 QT 中制作模拟对象。我正在尝试使用 Gmock,但我不知道如何使用它。现在,我在 QT 中创建项目 TestGmock(QT 应用程序),并将 gmock-1.7.0 中的包含文件夹(从https://code.google.com/下载)复制到 TestGmock 项目目录(与 gtest 相同) . 在主类中:
#include <QCoreApplication>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
int main(int argc, char *argv[])
{
testing::InitGoogleMock (&argc, argv);
return RUN_ALL_TESTS();
}
但是错误:
- C:\Qt\Qt5.2.1\Tools\QtCreator\bin\TestGmock\main.cpp:6: 错误:未定义引用 `testing::InitGoogleMock(int*, char**)'
- C:\Qt\Qt5.2.1\Tools\QtCreator\bin\TestGmock\gtest\gtest.h:2288: 错误:未定义对 `testing::UnitTest::GetInstance()' 的引用
- C:\Qt\Qt5.2.1\Tools\QtCreator\bin\TestGmock\gtest\gtest.h:2288: 错误:未定义对 `testing::UnitTest::Run()' 的引用 collect2.exe:-1:
- 错误:错误:ld 返回 1 退出状态
请帮助我在 QT 中使用 gmock 和 gtest。