Googletest export

Docs: Clarify that expectations must be set before mocks are exercised
PiperOrigin-RevId: 373644072
This commit is contained in:
Abseil Team
2021-05-13 13:15:34 -07:00
committed by Dino Radaković
parent 662fe38e44
commit eb6e9273dc
3 changed files with 25 additions and 29 deletions

View File

@@ -262,8 +262,9 @@ when you allocate mocks on the heap. You get that automatically if you use the
`gtest_main` library already.
**Important note:** gMock requires expectations to be set **before** the mock
functions are called, otherwise the behavior is **undefined**. In particular,
you mustn't interleave `EXPECT_CALL()s` and calls to the mock functions.
functions are called, otherwise the behavior is **undefined**. Do not alternate
between calls to `EXPECT_CALL()` and calls to the mock functions, and do not set
any expectations on a mock after passing the mock to an API.
This means `EXPECT_CALL()` should be read as expecting that a call will occur
*in the future*, not that a call has occurred. Why does gMock work like that?