When I test a method using
BOOST_CHECK_NO_THROW( method_to_test() );
and an exception is thrown, it displays that an exception was thrown, but never the exception's message like this:
test.cpp(14): error in "test": incorrect exception my_exception is caught
Is it possible to print the exception message as well, i.e. the string returned by my_exception.what()
? my_exception
is derived from std::exception
and overloads what()
.
I found myself annoyed by the same problem with BOOST_REQUIRE_NO_THROW
. I solved it by simply removing the BOOST_REQUIRE_NO_THROW
. This results in output like:
unknown location(0): fatal error in "TestName": std::runtime_error: Exception message
and aborts the test (but goes on with the next text), which is what I wanted. This doesn't help much if you wanted to use BOOST_CHECK_NO_THROW or BOOST_WARN_NO_THROW, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With