Receive Google Exception Error Message

I am using the Google Test Framework for my project. I selected an exception from the code as:

throw DerivedClassException("message"); 

and in the test frame using:

 ASSERT_THROW(commond(), DerivedClassException); 

I want to receive a message with the what() API. Any way to get an accurate exception message.

+7
c ++ exception-handling c ++ 11 googletest
source share
1 answer

The only way to check for an exception is to check it in the test:

 void test_foo( MyTest, TestException ) { try { functionThatThrowsException(); FAIL(); } catch( const DerivedClassException& err ) { // check exception ASSERT_STREQ( "error message", err.what() ); } } 
+8
source share

All Articles