[英]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.