Exception inside ON_CALL will not be catched
Open
bug
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
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**
```cpp
class MockClass : public SomeClass
{
public:
MOCK_METHOD(void, someFunction, (), (override);
}
```
**MockClassTests**
```cpp
TEST
{
MockClass mock;
ON_CALL(mock, someFunction).WillByDefault([]() {
throw std::runtime_error{"error message"};
});
EXPECT_THROW(mock.someFunction(), std::runtime_error);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.