Вопрос

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.

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top