I have some expectations like EXPECT_CALL (...)
EXPECT_CALL(t1, foo()).Times(1);
I want to create the oposite. I expect that a certain function won't be executed.
What is the method I should use?
Something like EXPECT_NOT_CALL (...)
?
In GTest something similar to EXPECT_NOT_CALL
doesn't exist however, there are several options to receive this behaviour:
1.Create a StrictMock. In StrictMock
any unexpected called cause a failure.
2.Use .Times(0)
:
EXPECT_CALL(t1, foo()).Times(0);
In this option you use the count mechanism however, it checks if the value is 0
.(so any call leads a failure...)
3.Use method 2
and create a Macro
:
#define EXPECT_NOT_CALL(a,b) EXPECT_CALL(a, b).Times(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With