Boost logo

Boost Users :

Subject: [Boost-users] [Boost.Test] Detail lost when using BOOST_*_NO_THROW
From: Adam Nielsen (a.nielsen_at_[hidden])
Date: 2013-12-22 04:17:45


Hi again,

While developing tests I sometimes find that functions that should not
throw exceptions do. Because this is an unexpected situation, I would
like to know what exception has been thrown so I know what problem to
look for in my test design.

Unfortunately the Boost.Test framework only provides a terse message
like this:

  test.cpp(123): fatal error in "fnTest": exception thrown by test();

It doesn't tell you which exception was thrown, nor the reason why.

Is there some way to tell Boost.Test to include the exception message
(from what()) if the exception derives from std::exception? This would
make problem solving much quicker as you would not have to run the
tests through a debugger to see which exception is being thrown and why.

There is some discussion about this on Stack Overflow[1] but the
consensus seems to be the best solution is not to use
BOOST_*_NO_THROW. If you don't use these and an exception is thrown, a
lot more detail is provided.

Assuming this is a limitation in Boost.Test, would it be possible to
add this as a feature so that future versions include the same level of
detail whether you use BOOST_*_NO_THROW or not?

Many thanks,
Adam.

[1] http://stackoverflow.com/questions/15133259/boost-check-no-throw-how-to-get-exception-message-printed


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net