Interleaving EXPECT_CALL()s and calls to the mock functions
问题 The Google Mock documentation says: Important note: Google Mock 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. Does anyone know any details behind this restriction? I have a number of unit tests which definitely violate this rule but seem to function properly, however. 回答1: I have to disagree with @Marko Popovic's assessment, and believe what he's