summaryrefslogtreecommitdiffstats
path: root/googlemock/docs/cook_book.md
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2020-12-21 20:41:17 (GMT)
committerDerek Mauro <dmauro@google.com>2020-12-22 17:15:41 (GMT)
commitca4b7c9ff4d8a5c37ac51795b03ffe934958aeff (patch)
tree9b90d078223828eb4acf5b274e4cc3c5cb79ecfd /googlemock/docs/cook_book.md
parent4f6fa70870de48cf0db655acc9cb8c30b2760ec9 (diff)
downloadgoogletest-ca4b7c9ff4d8a5c37ac51795b03ffe934958aeff.zip
googletest-ca4b7c9ff4d8a5c37ac51795b03ffe934958aeff.tar.gz
googletest-ca4b7c9ff4d8a5c37ac51795b03ffe934958aeff.tar.bz2
Googletest export
Give each of Naggy/Nice/StrictMock a base class whose constructor runs before the mocked class's constructor, and a destructor that runs after the mocked class's destructor, so that any mock methods run in either the constructor or destructor use the same strictness as other calls. PiperOrigin-RevId: 348511612
Diffstat (limited to 'googlemock/docs/cook_book.md')
-rw-r--r--googlemock/docs/cook_book.md10
1 files changed, 0 insertions, 10 deletions
diff --git a/googlemock/docs/cook_book.md b/googlemock/docs/cook_book.md
index cfe5858..cd64150 100644
--- a/googlemock/docs/cook_book.md
+++ b/googlemock/docs/cook_book.md
@@ -429,16 +429,6 @@ limitations):
2. `NiceMock<MockFoo>` and `StrictMock<MockFoo>` may not work correctly if the
destructor of `MockFoo` is not virtual. We would like to fix this, but it
requires cleaning up existing tests.
-3. During the constructor or destructor of `MockFoo`, the mock object is *not*
- nice or strict. This may cause surprises if the constructor or destructor
- calls a mock method on `this` object. (This behavior, however, is consistent
- with C++'s general rule: if a constructor or destructor calls a virtual
- method of `this` object, that method is treated as non-virtual. In other
- words, to the base class's constructor or destructor, `this` object behaves
- like an instance of the base class, not the derived class. This rule is
- required for safety. Otherwise a base constructor may use members of a
- derived class before they are initialized, or a base destructor may use
- members of a derived class after they have been destroyed.)
Finally, you should be **very cautious** about when to use naggy or strict
mocks, as they tend to make tests more brittle and harder to maintain. When you