To mock a method, you do not re-declare the class, you inherit from it
and overwrite the method with the mock method. Does that make sense?
If not, can you clarify what exactly your problem is? :-)
Cheers,
/Manuel
Yes, this is what gmock is all about. If the methods in
AlreadyDeclaredClassThatINeed are virtual, just follow the guide here:
http://code.google.com/p/googlemock/wiki/ForDummies
Cheers,
/Manuel
>
>
> On Jul 22, 2:10 am, Manuel Klimek <kli...@google.com> wrote:
>> On Wed, Jul 21, 2010 at 11:30 PM, buddyboy <smiling.gyps...@gmail.com> wrote:
>> > All of the examples I've found so far show that mocking is done in the
>> > following way
>>
>> > class whatever
>> > {
>> > public:
>> > MOCK_METHOD0(CoolFunction,int(void));
>> > };
>>
>> > But, what if I need to create the mock method in a seperate file
>> > (outside the class declaration). How do I do that?
>>
>> > My code under test includes the real header file for a class whose
>> > methods I want to mock. I don't want to re-declare the class, I just
>> > want to mock a method in it. Is it possible, and if so how?
>>
>> To mock a method, you do not re-declare the class, you inherit from it
>> and overwrite the method with the mock method. Does that make sense?
>> If not, can you clarify what exactly your problem is? :-)
>>
>> Cheers,
>> /Manuel
>
--
Manuel Klimek (http://go/klimek)