Question

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.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top