Combining two mocks in one class (multiple mock inheritance)? #4661
Unanswered
Griffon26
asked this question in
Community Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We like to write one mock per interface and recently discovered that when a class implements two interfaces and we want to have a single mock for that class, we cannot do it by inheriting from the mocks of both interfaces. For example NiceMock only has an effect on one of the two interfaces when we do this.
Is there an easy way to combine two mocks into one without the problems you get from inheriting from two mocks and without writing a mock specifically for the combination and repeating all the MOCK_METHOD lines?
It seems like it would be a useful utility to have a template class CombinedMock<Mock1, Mock2> that could do this with one line of code.
Beta Was this translation helpful? Give feedback.
All reactions