views:

144

answers:

2

I am very new to Google Mock and to StackOverflow, sorry in advance if my question is not well posed.

I am trying to mock a templated method.

Here is the class containing the method to mock :

class myClass
{
public:
    virtual ~myClass() {}

    template<typename T>
    void myMethod(T param);
}

How can I mock the method myMethod using Google Mock ?

Thanks in advance for all your answers.

+1  A: 

In the current version of Google Mock you can only mock virtual functions, see the documentation in the project's page.

Ismael
Yes, you are right Ismael, for more information, I found this link : http://groups.google.com/group/googlemock/browse_thread/thread/e52b27b7d9b20145So, there is a workaround to mock templated methods.
Xavier V.
A: 

Not true. See the documentation: Mocking Nonvirtual Methods.

I haven't seen any way to mock templated methods, though.

Michael
Oops, didn't see the reply from Xavier V.
Michael
It's not the best to mock templated methods...I hope in the next GMock version, we will be able to.
Xavier V.