In our project we are using Google Mock, but in multiple places we are making contructions in our production code, only to make sure classes are "mockable". We do this because we want to have the benefits of Google Mock, but on the other side we would rather have more optimal production code. The following case is something we do often, and would like to get rid off.
class A{
public:
void doSomething(); //Does something with _someB
void setSomeB(B* mockedB); //This is only here for GMock
private:
B* _someB; //This should not be a pointer, it is a pointer only for GMock
}
This is only a simplified example as you can see, I left out the details. Basically we want to get rid of B being a pointer. The reason we have it as a pointer, is that we can subclass B in our test code (mock it) and set it with that setter.
Is there any way to avoid this? Can't we let B be scoped in the class?
Thanks