There is a problem I met using GMock with 3rdParty UT-engine based on exceptions handling.
If I enables throwing exceptions from GMock: ::testing::GTEST_FLAG(throw_on_failure) = true
Then in test case if I created a local Mock object with invalid expectation call then I will get exception in exception:
Because of invalid arguments passed to the method.
During stack unwinding we will destroy Mock object and will call VerifyAndClearExpectationsLocked(); from~FunctionMockerBase()
These behavior obviously leads to process termination.
The suggestion is to check whether we already in unhandled exception or not before Verifing expectations in destructor:
if (!std::uncaught_exception())
{
VerifyAndClearExpectationsLocked();
}
There is a problem I met using GMock with 3rdParty UT-engine based on exceptions handling.
If I enables throwing exceptions from GMock:
::testing::GTEST_FLAG(throw_on_failure) = true
Then in test case if I created a local Mock object with invalid expectation call then I will get exception in exception:VerifyAndClearExpectationsLocked();
from~FunctionMockerBase()
These behavior obviously leads to process termination.
The suggestion is to check whether we already in unhandled exception or not before Verifing expectations in destructor: