vendredi 9 octobre 2020

Is it possible to mock private/protected methods from a c++ class without inheriting from it?

I am trying to use gMock framework to mock a method functionality for one of my classes. But the class is declared final. As per working through examples in https://chromium.googlesource.com/external/github.com/pwnall/googletest/+/HEAD/googlemock/docs/for_dummies.md#how-to-define-it and https://chromium.googlesource.com/external/github.com/google/googletest/+/refs/tags/release-1.8.0/googlemock/docs/CookBook.md#mocking-private-or-protected-methods I have this understanding that the mocking interface must inherit from the actual class containing the function to be mocked. In my case though, the actual class is declared final . Is there any workaround for this ?

Aucun commentaire:

Enregistrer un commentaire