Search code examples
c++exceptiongoogletestgooglemock

GoogleTest: How to catch a generic exception in EXPECT_THROW?


Hi i want to catch a generic exception in function EXPECT_THROW GoogleTest ,which can catch all the type of exception thrown, irrespective of exception type.

Is their any similar way as we used to catch in try-catch block.

catch (...) {
 
}

Solution

  • EXPECT_ANY_THROW is for this purpose.

    See Advanced googletest topics.