使用Gmock基础进行单元测试:处理在另一个名称空间中定义的函数参数

时间:2017-09-14 05:40:03

标签: unit-testing gmock

我一直在努力,但无法从在线资源中搜索任何相关帮助。作为UT的新手,我想我最好的选择就是直接问这里。如果您没有直接答案,也非常感谢任何相关的资源链接。

我的问题听起来像这样:



//My environment is in C++
//The below code snippet is for reader to understand why I encounter build errors and how should I resolve

//Source code .cpp file (target to run UT on)
class realChild : public virtualParent
{
public:
  bool member_func (const OtherNamespace::CustomizedParams &sParams,
                    int other_Params,
                    char other_Params2) const;
}

//Header .h file - the class interface
class virtualParent
{
  virtual bool member_func (const OtherNamespace::CustomizedParams &sParams,
                    int other_Params,
                    char other_Params2) const = 0;
}


//UT .cpp file - the place that I wanted to mock the class to perform unit test
#include "OtherNamespace.h"
using OtherNamespace
class MockrealChild : public virtualParent
{
public:
  MOCK_METHOD3(member_func, bool(const CustomizedParams, int, char));
}




结束了这样的构建错误,我找不到任何可以克服的建设性建议。

错误:' OtherNamespace :: CustomizedParams'

的转发声明

0 个答案:

没有答案