aboutsummaryrefslogtreecommitdiff
path: root/docs/gmock_cook_book.md
AgeCommit message (Collapse)AuthorFilesLines
2024-05-02Add example using EXPECT statement in custom matcherAbseil Team1-3/+32
`EXPECT_...` statements can be used inside matcher definitions – this is an important option that is glossed over in this documentation. Users should definitely be aware of this option, since writing custom messages to the `result_listener` can be very cumbersome (and unnecessary) sometimes. This change adds a relevant example and includes the associated error message it provides on failure. PiperOrigin-RevId: 630206661 Change-Id: Idee00ba77ce3c1245597aa082f9cd0efff16aceb
2023-10-03gmock_cook_book: Document `DoAll`'s return type requirementDino Radakovic1-0/+6
The requirement is vaguely documented by "Only the return value of the last action in the sequence will be used.". However, this can be misleading, as users could potentially expect default-constructed values to be returned in absence of a matching return type. PiperOrigin-RevId: 570450839 Change-Id: Ibd98a6e6b2aaf2a8cfc15ed6aeab442526eab98e
2023-07-28Adjust includes to use <> instead of "", consistent with quickstart pages.Abseil Team1-1/+1
Right now, gtest documentation uses different #include syntax. The quickstart pages (e.g., http://google.github.io/googletest/quickstart-bazel.html#create-and-run-a-binary) are checked in with `#include <gtest/gtest.h>` However, other documentation (such as the primer) uses `#include "gtest/gtest.h"` (e.g., https://google.github.io/googletest/primer.html#writing-the-main-function). PiperOrigin-RevId: 551878641 Change-Id: Iab93cc1da3ef4870a07b624071b75d6e9d3568c1
2023-07-19Fix typo in gmock_cook_book.mdAnton Sosnin1-2/+2
2023-06-22Update code examples in the gMock Cookbook following C++ best practices.Abseil Team1-22/+24
PiperOrigin-RevId: 542564354 Change-Id: Ia3307f13f845c662c88fb7303112f41ef8c56b28
2023-04-17Update gMock Cookbook to reflect deprecation of testing::ByMoveAbseil Team1-18/+13
PiperOrigin-RevId: 524868227 Change-Id: I702ede27570e3d3f06d534d6ccf8b39689105d07
2023-01-18Mention using MockFunction as a way to mock free functions.Abseil Team1-0/+4
PiperOrigin-RevId: 502901538 Change-Id: I0cf351b9ad1411ae9c45e09550c24e006a24e179
2022-12-20Fix a typo in the documentation for "Using Predicates as Matchers".Abseil Team1-1/+1
PiperOrigin-RevId: 496679950 Change-Id: I2842050902876231d49a142165bcbb88d737505d
2022-12-19Specify a name for a `Property` in a code example.Abseil Team1-1/+1
It is good practice to specify a name for the `testing::Property` matcher's use in diagnostics, and we should do so in our examples. PiperOrigin-RevId: 496406309 Change-Id: Ibb4d1ba63771b5d6855442b91564027cda8ddaca
2022-12-14Fix a typo in the gMock sample code for Defining a Custom Matcher Class.Abseil Team1-1/+1
EXPECT_CALL doesn't seem to make much sense here. I think the intent was to use EXPECT_THAT instead. PiperOrigin-RevId: 495427663 Change-Id: I39a16ea37282729d34017c6bcd331a60cedf1fbe
2022-11-23This commit fixes a minor verb conjugation error in gmock_cook_book.md.Abseil Team1-1/+1
PiperOrigin-RevId: 490601453 Change-Id: I733b2ed8740b1c809dddb166a42993b869198469
2022-11-20Change MakeUnique -> std::make_unique in docsDenis Hananein1-4/+4
2022-09-09Use UnorderedElementsAre in example about using matchers with mapsAbseil Team1-6/+7
PiperOrigin-RevId: 473353707 Change-Id: Ief5bdbd2b8e28bac8f47be9aaeac4bb93875a793
2022-06-13gmock_cook_book.md: Delete superfluous statement from 2014.Abseil Team1-2/+1
PiperOrigin-RevId: 454677195 Change-Id: I7a1419e22d617db41a5c310bc6f6158ba4cec1ab
2022-05-10gmock-actions: make OnceAction public.Aaron Jacobs1-12/+51
So that it can be referenced in conversion operators for actions that need to know the concrete return type. PiperOrigin-RevId: 447889344 Change-Id: I643d3298bc8effd08741282a956c221f9d67d378
2022-04-28Rewrite "Testing a Certain Property of an Object" as "Defining a Custom ↵Abseil Team1-17/+22
Matcher Class", and fix the code examples. PiperOrigin-RevId: 445252626 Change-Id: I9f038cb669d3da6743606343c2341fc59725d722
2021-12-02Fix typo in GoogleMock Cookbook.Abseil Team1-1/+1
PiperOrigin-RevId: 413674665 Change-Id: I466f87348390f42434a70f183efdf0557be9dddd
2021-10-13Googletest exportAbseil Team1-0/+1
add missing using ::testing::DoAll when DoAll used in example PiperOrigin-RevId: 402416497
2021-09-16Fix typos discovered by codespellChristian Clauss1-3/+3
2021-08-19Simplify example code with c++11theidexisted1-4/+1
2021-08-05typo fix gmock_cook_bookBerke1-1/+1
2021-06-02Googletest exportAbseil Team1-1/+1
Create new Mocking Reference PiperOrigin-RevId: 376951575
2021-06-02Googletest exportAbseil Team1-45/+2
Create Assertions Reference PiperOrigin-RevId: 375824718
2021-05-19Googletest exportAbseil Team1-1/+1
Fix a comment in a code snippet. PiperOrigin-RevId: 374504337
2021-05-18Googletest exportAbseil Team1-27/+17
Docs: Clarify that expectations must be set before mocks are exercised PiperOrigin-RevId: 373644072
2021-04-29Googletest exportAbseil Team1-1/+2
Clean up links to Matchers Reference PiperOrigin-RevId: 370821457
2021-04-29Googletest exportAbseil Team1-5/+6
Move matchers reference from cheat sheet into its own document PiperOrigin-RevId: 370749693
2021-04-29Googletest exportAbseil Team1-1/+1
Update the `DescribeTo` signature in the code example at the Writing New Polymorphic Matchers section in gmock_cook_book. `os` should be a pointer to be consistent with the implementation, which dereference it as `*os`. PiperOrigin-RevId: 370693387
2021-04-07Googletest exportAbseil Team1-9/+1
Update the example for Notify to use a lambda. It is much less boilerplate and easier to remember. PiperOrigin-RevId: 367284222
2021-03-25Googletest exportAbseil Team1-3/+3
Clarify explanation of mocking free functions PiperOrigin-RevId: 364943561
2021-03-25Googletest exportAbseil Team1-3/+3
Code style cleanup in docs PiperOrigin-RevId: 364907938
2021-02-19Googletest exportAbseil Team1-3/+17
Add files for GitHub Pages PiperOrigin-RevId: 358289110
2021-02-18Googletest exportAbseil Team1-4/+8
Add files for GitHub Pages PiperOrigin-RevId: 357096486
2021-02-18Googletest exportAbseil Team1-4/+0
Internal change PiperOrigin-RevId: 356867746
2021-02-05Googletest exportAbseil Team1-49/+88
Fix table formatting in cookbook PiperOrigin-RevId: 355659722
2021-02-05Googletest exportAbseil Team1-2/+4
Add a note to recommend against using `Property()` for functions that the test author does not own. PiperOrigin-RevId: 355295183
2021-02-05Googletest exportAbseil Team1-0/+3
Document the fact that MatchAndExplain(T, MatchResultListener*) is supported. PiperOrigin-RevId: 354172275
2021-01-26Googletest exportAbseil Team1-0/+2
Add missing `is_gtest_matcher` to the polymorphic matcher example. PiperOrigin-RevId: 353881883
2021-01-26Googletest exportAbseil Team1-17/+1
Delete internal tags from docs PiperOrigin-RevId: 353769887
2021-01-26Googletest exportAbseil Team1-9/+9
Merge CONTRIBUTORS, delete LICENSEs in googletest/ and googlemock/ PiperOrigin-RevId: 352558822
2021-01-15Googletest exportAbseil Team1-1/+1
Fixes #3222, fixes #3225, closes #3223 PiperOrigin-RevId: 352066131
2021-01-15Googletest exportAbseil Team1-0/+2
Add "using is_gtest_matcher = void" to the DivisibleBy7Matcher example. PiperOrigin-RevId: 351797821
2021-01-13Googletest exportAbseil Team1-66/+113
Change Matcher<T> to allow binding an implementation by value directly: - Drop the requirement of MatcherInterface. Doing manual type erasure avoid extra layers in many cases. - Avoid the adaptor for `MatcherInterface<T>` and `MatcherInterface<const T&>` mismatch. - Use a small object optimization when possible. This makes things like `_` and `Eq(1)` really cheap and do not require memory allocations. - Migrate some matchers to the new model to speed them up and to test the new framework. More matchers to come in future changes. PiperOrigin-RevId: 350580998
2021-01-13Googletest exportAbseil Team1-0/+4267
Move all docs into top-level docs/ directory PiperOrigin-RevId: 350211277