googletest
googletest copied to clipboard
Exception inside ON_CALL will not be catched
Hi,
When I use ON_CALL with WillByDefault and try to throw exception inside it, that will not be catched by EXPECT_THROW. Also I am getting an error which says that exception was thrown during tests.
For example:
MockClass
class MockClass : public SomeClass
{
public:
MOCK_METHOD(void, someFunction, (), (override);
}
MockClassTests
TEST
{
MockClass mock;
ON_CALL(mock, someFunction).WillByDefault([]() {
throw std::runtime_error{"error message"};
});
EXPECT_THROW(mock.someFunction(), std::runtime_error);
}