Search code examples
c++11googletestgooglemockhippomocks

Compilation error looser throw specifier for gtest derived classes with HippoMocks member in C++11


I am getting below error while compiling my test cases derived from testing::Test of google test with C++11. Below error will be thrown if my derived class has HippoMock::MockRepository member.

looser throw specifier for virtual MyTestClass::~MyTestClass noexcept(false) error overriding 'virtual testing::Test::~Test() noexcept(true)'

This error is reported since HippoMock::MockRespository destructor throws exception and define as noexcept(false), However google test destructor defined as 'virtual testing::Test::~Test()'

Resolution:

  1. Mark all derived destructor as noexcept(false). However this is not feasible and may cause crash since HippoMock::MockRepository throws exception from destructor.
  2. Declare google test testing::Test::~Test() noexcept(false). However I really don`t know the consequences, Also our newer code using google Mock.

Please note since legacy code contain lot of HippoMocks code its not feasible to replace all with Google Mock. Also newer code is using google mock.

I just want to know , What are the consequences of defining gtest testing::Test::~Test() noexcept(false) ?


Solution

  • This has resolved by updating to latest version of HippoMocks https://github.com/dascandy/hippomocks.