测试自动化 2011/06/11 - 1 一个最简单的GMock测试程序HelloGMock

Google Mock使用:做一个最简单的GMock例子并运行起来(耗时约3小时)

 

1. 生产代码:Hello.h, SayHello.h

 

[root@localhost HelloGMock]# cat Hello.h
#ifndef __HELLO_
#define __HELLO_

class Hello {
public:
        virtual void Hi() = 0;
};

#endif

 

[root@localhost HelloGMock]# cat SayHello.h
#include "Hello.h"

class SayHello {
public:
        SayHello(Hello *h) { hello = h; }
        //SetIt(Hello *h) { hello = h; )
        void SayIt() { hello->Hi(); }
private:
        Hello * hello;
};

 

2. 测试代码:SayHelloTest.cpp MockHello.h

 

[root@localhost HelloGMock]# cat MockHello.h

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "Hello.h"

class MockHello : public Hello {

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Base path: /home/dama/demo02_ws Source space: /home/dama/demo02_ws/src Build space: /home/dama/demo02_ws/build Devel space: /home/dama/demo02_ws/devel Install space: /home/dama/demo02_ws/install #### #### Running command: "make cmake_check_build_system" in "/home/dama/demo02_ws/build" #### -- Using CATKIN_DEVEL_PREFIX: /home/dama/demo02_ws/devel -- Using CMAKE_PREFIX_PATH: /home/dama/demo02_ws/devel;/home/dama/demo01_ws/devel;/opt/ros/noetic -- This workspace overlays: /home/dama/demo02_ws/devel;/home/dama/demo01_ws/devel;/opt/ros/noetic -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") -- Using PYTHON_EXECUTABLE: /usr/bin/python3 -- Using Debian Python package layout -- Using empy: /usr/lib/python3/dist-packages/em.py -- Using CATKIN_ENABLE_TESTING: ON -- Call enable_testing() -- Using CATKIN_TEST_RESULTS_DIR: /home/dama/demo02_ws/build/test_results -- Forcing gtest/gmock from source, though one was otherwise available. -- Found gtest sources under '/usr/src/googletest': gtests will be built -- Found gmock sources under '/usr/src/googletest': gmock will be built -- Found PythonInterp: /usr/bin/python3 (found version "3.8.10") -- Using Python nosetests: /usr/bin/nosetests3 -- catkin 0.8.10 -- BUILD_SHARED_LIBS is on -- BUILD_SHARED_LIBS is on -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~ traversing 1 packages in topological order: -- ~~ - hello_vscode -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- +++ processing catkin package: 'hello_vscode' -- ==> add_subdirectory(hello_vscode) CMake Error at /opt/ros/noetic/share/catkin/cmake/catkin_install_python.cmake:86 (message): catkin_install_python() called with non-existing file '/home/dama/demo02_ws/src/hello_vscode/scripts/hello_vscode_p.py'. Call Stack (most recent call first): hello_vscode/CMakeLists.txt:162 (catkin_install_python) -- Configuring incomplete, errors occurred! See also "/home/dama/demo02_ws/build/CMakeFiles/CMakeOutput.log". See also "/home/dama/demo02_ws/build/CMakeFiles/CMakeError.log". make: *** [Makefile:544:cmake_check_build_system] 错误 1 Invoking "make cmake_check_build_system" failed
最新发布
06-11

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值