设置谷歌模拟 1.6
Setting Up Google Mock 1.6
我正在尝试遵循测试驱动开发的现代C++编程,为此,本书指导读者安装 谷歌模拟 1.6。尝试这样做,我从这里下载了源代码。然后根据这本书我做的:mkdir build
cd build
cmake ..
make
myComputer:build me$ cmake ..
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- The C compiler identification is AppleClang 8.0.0.8000042
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:56 (add_subdirectory):
add_subdirectory given source "../gtest" which is not an existing
directory.
CMake Error at CMakeLists.txt:61 (config_compiler_and_linker):
Unknown CMake command "config_compiler_and_linker".
-- Configuring incomplete, errors occurred!
See also "/Users/me/Downloads/googlemock-release-1.6.0 3/build/CMakeFiles/CMakeOutput.log".
这。。/gtest 目录确实丢失了。因为这些是目录:
CHANGES COPYING build include scripts
CMakeLists.txt Makefile.am build-aux make src
CONTRIBUTORS README configure.ac msvc test
更令人困惑的是这些说明:
You will also need to build Google Test, which is nested within Google Mock.
cd $GMOCK_HOME/gtest
mkdir mybuild
cd mybuild
cmake ..
make
我查看了自述文件,似乎没有任何有助于解决此问题的内容。任何帮助/指导都会超级棒!
正如你在这里看到的,Google Mock已经被吸收到GoogleTest项目中。
有多种方法可以安装 GoogleTest,如 GoogleTest 自述文件中所述。由于您似乎正在使用CMake,因此建议您按照以下步骤操作
合并到现有的CMake项目中
你也可以把所有应该放到CMakeLists.txt放到CMakeLists.GTest中,然后只把include(CmakeLists.GTest)
放到CMakeLists.txt中。
如果您想确定应该合并的GoogleTest的固定版本,则可以在 CMakeLists.txt.in 中使用GIT_TAG
例如release-1.8.0´ instead of
master'。
将GoogleTest合并到您的项目中后,您可以通过创建例如FooTest为类Foo
添加gtest.cpp其中包括gtest/gtest.h
和Foo.h
。因此,您还必须将add_executable(FooTarget FooTest.cpp)
和target_link_libraries(FooTarget gtest)
放入相应的CMakeLists.txt中。
您还可以在这些幻灯片上找到对此的简短描述,以及如何将GoogleTests集成到ctest中)。
你需要在 gmock dir 中有一个 gtest。 我最初遇到了与您相同的错误,然后从 https://github.com/google/googletest 中获取了 gtest 版本 1.6 并将其放置在 gmock 根目录中并成功构建了它。
- 谷歌模拟和覆盖关键字
- 如何在谷歌模拟中匹配 C 样式数组
- 如何使用不同的谷歌模拟运行相同的谷歌测试用例?
- 在谷歌测试中创建模拟类的向量
- 谷歌模拟嘲笑非虚拟函数
- C++ 谷歌模拟/单元测试:模拟方法未调用,原始方法是
- 无法使用谷歌模拟模拟CDatabase打开功能
- 谷歌模拟如何在测试中使用模拟
- 谷歌模拟:嘲笑家长类?
- EXPECT_CALL在谷歌测试中没有模拟
- 为什么谷歌测试/模拟显示 std::unique_ptr 泄露的模拟对象错误?
- 谷歌模拟类似乎没有实现
- 如何测试基类中的方法是否已使用谷歌模拟调用和执行?
- 谷歌模拟分割错误与简单的EXPECT_CALL案例
- 设置谷歌模拟 1.6
- 谷歌模拟 - 怎么说"function must be called ONCE with a certain parameter but ok to be called many times with
- 谷歌模拟 - 保存EXPECT_CALL然后重复使用和更改子句
- 谷歌模拟 - 如何EXPECT_CALL变量名称,即标识符
- 谷歌模拟单例C++类
- 谷歌模拟EXPECT_CALL具有微小的行为变化