From 04e9129ce6c070c631a429f6ca6cc0ea84c70c54 Mon Sep 17 00:00:00 2001 From: sidhansu10 Date: Tue, 30 Dec 2025 19:40:02 +0530 Subject: [PATCH] docs: add NaggyMock description to gmock cookbook --- docs/gmock_cook_book.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 22ad0214..0fef5410 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -457,6 +457,21 @@ TEST(...) { // is called. } ``` +The default behavior for mock objects in gMock is *naggy*. That is, if you use +`MockFoo` directly (without wrapping it in `NiceMock` or `StrictMock`), +uninteresting calls will be allowed but will generate warnings. + +You can also explicitly state this behavior using `NaggyMock`: + +```cpp +using ::testing::NaggyMock; + +TEST(...) { + NaggyMock mock_foo; + EXPECT_CALL(mock_foo, DoThis()); + ... code that uses mock_foo ... +} +``` {: .callout .note} NOTE: `NiceMock` and `StrictMock` only affects *uninteresting* calls (calls of