@@ -781,28 +781,12 @@ perhaps your test doesn't need to mock `Concrete()` at all (but it would be
781
781
oh-so painful to have to define a new mock class whenever you don't need to mock
782
782
one of its methods).
783
783
784
- The trick is to leave a back door in your mock class for accessing the real
785
- methods in the base class:
786
-
787
- ```cpp
788
- class MockFoo : public Foo {
789
- public:
790
- // Mocking a pure method.
791
- MOCK_METHOD(void, Pure, (int n), (override));
792
- // Mocking a concrete method. Foo::Concrete() is shadowed.
793
- MOCK_METHOD(int, Concrete, (const char* str), (override));
794
-
795
- // Use this to call Concrete() defined in Foo.
796
- int FooConcrete(const char* str) { return Foo::Concrete(str); }
797
- };
798
- ```
799
-
800
- Now, you can call `Foo::Concrete()` inside an action by:
784
+ You can call `Foo::Concrete()` inside an action by:
801
785
802
786
```cpp
803
787
...
804
788
EXPECT_CALL(foo, Concrete).WillOnce([&foo](const char* str) {
805
- return foo.FooConcrete (str);
789
+ return foo.Foo::Concrete (str);
806
790
});
807
791
```
808
792
@@ -811,7 +795,7 @@ or tell the mock object that you don't want to mock `Concrete()`:
811
795
```cpp
812
796
...
813
797
ON_CALL(foo, Concrete).WillByDefault([&foo](const char* str) {
814
- return foo.FooConcrete (str);
798
+ return foo.Foo::Concrete (str);
815
799
});
816
800
```
817
801
0 commit comments