diff options
author | Abseil Team <absl-team@google.com> | 2021-02-19 00:18:34 (GMT) |
---|---|---|
committer | Derek Mauro <dmauro@google.com> | 2021-02-19 18:55:48 (GMT) |
commit | d9c309fdab807b716c2cf4d4a42989b8c34f712a (patch) | |
tree | 63b898af44e9476e1b5b99782c8ffad1708ffec2 /docs/gmock_for_dummies.md | |
parent | daa0df7b410cfed62ef474446eff22148a272a8d (diff) | |
download | googletest-d9c309fdab807b716c2cf4d4a42989b8c34f712a.zip googletest-d9c309fdab807b716c2cf4d4a42989b8c34f712a.tar.gz googletest-d9c309fdab807b716c2cf4d4a42989b8c34f712a.tar.bz2 |
Googletest export
Add files for GitHub Pages
PiperOrigin-RevId: 358289110
Diffstat (limited to 'docs/gmock_for_dummies.md')
-rw-r--r-- | docs/gmock_for_dummies.md | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/docs/gmock_for_dummies.md b/docs/gmock_for_dummies.md index 6dca904..4f7daf5 100644 --- a/docs/gmock_for_dummies.md +++ b/docs/gmock_for_dummies.md @@ -334,6 +334,7 @@ says that the `turtle` object's `GetX()` method will be called five times, it will return 100 the first time, 150 the second time, and then 200 every time. Some people like to call this style of syntax a Domain-Specific Language (DSL). +{: .callout .note} **Note:** Why do we use a macro to do this? Well it serves two purposes: first it makes expectations easily identifiable (either by `grep` or by a human reader), and second it allows gMock to include the source file location of a @@ -543,6 +544,7 @@ error, as the last matching expectation (#2) has been saturated. If, however, the third `Forward(10)` call is replaced by `Forward(20)`, then it would be OK, as now #1 will be the matching expectation. +{: .callout .note} **Note:** Why does gMock search for a match in the *reverse* order of the expectations? The reason is that this allows a user to set up the default expectations in a mock object's constructor or the test fixture's set-up phase @@ -551,6 +553,7 @@ body. So, if you have two expectations on the same method, you want to put the one with more specific matchers **after** the other, or the more specific rule would be shadowed by the more general one that comes after it. +{: .callout .tip} **Tip:** It is very common to start with a catch-all expectation for a method and `Times(AnyNumber())` (omitting arguments, or with `_` for all arguments, if overloaded). This makes any calls to the method expected. This is not necessary |