我使用谷歌测试和谷歌模拟。有一个模拟对象,我希望有一个方法调用OnConnectionError()
通知 absl::Notification 对象done
3 次。
absl::Notification done;
EXPECT_CALL(*client, OnConnectionError(::testing::_)).Times(3)
.WillRepeatedly(Notify(&done));
bool result = client->ConnectToServer("localhost", 5000, 2);
done.WaitForNotificationWithTimeout(absl::Duration(absl::Seconds(30)));
该方法client->ConnectToServer
有一个循环,导致重复调用OnConnectionError
,这是完全正常的并且是所需的行为。
在 Windows 上,单元测试通过正常。当 jenkins 在 ubuntu 上运行它时,它会中止整个测试运行(不仅没有通过一个测试!!)并显示以下输出。
[notification.cc : 32] RAW: Notify() method called more than once for Notification object 0x7ffffde87320
不允许多次调用 Notification 对象吗?为什么在 Windows 上测试成功并在 ubuntu 上中止?
非常感谢您的支持!