[英]Mocking internal calls of a function being tested using googlemock
我是 Google Mock 的新手,根据我对文档和在线资源的理解,我无法确定我的问题的解决方案:
我有以下课程:
class A
{
public:
A() { }
int fun1()
{
//Some code
B b;
x = b.fun2();
//Some other code
}
};
class B
{
public:
B() { }
int fun2()
{
//Some code
y = C::fun3();
//Some code
}
};
class C
{
public:
static int fun3()
{
//Read a file and provide success if a certain pattern is found
}
};
现在我正在尝试为 A::fun1() 编写一个 Google 测试。 但是由于代码的结构(所有调用都是通过对象进行的,并且我没有可以用来初始化模拟等的基类,因此我无法成功模拟。
有人可以帮助我了解这是否可以用当前形式的 Google Mock 进行模拟? 请注意,我不允许更改原始源代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.