How to Google Mock a method called from a struct
-
29-10-2019 - |
문제
Let's have this example:
Class A{
public:
int Get();
}
In another file:
A a;
struct B{
int res = a.Get();
}
I would need to Google Mock Get method, however, I will also need to call the real one. I have tried with #ifdef, and it seems to work. Then I decided to mock it in the #ifdef section but it does nothing.
#ifdef UNIT_TEST
MOCK_METHOD0(A,Get);
#else
int A::Get(){....}
#endif
What am I doing wrong? Is there any cleaner way to do it? Please, any help would be much appreciate it.
올바른 솔루션이 없습니다
제휴하지 않습니다 StackOverflow