Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost.Test] Detail lost when using BOOST_*_NO_THROW
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2014-01-12 21:34:22


Adam Nielsen <a.nielsen <at> shikadi.net> writes:

>
> 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();

This is an output of BOOST_REQUIRE_NO_THROW, right?

There is very little reason to use this tool. Just leaving the expression
along would do the trick (just as the discussion in the link below suggests
and Richard in another reply). I probably should just remove this tool to
avoid confusion.
 
> 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.

Yep.
 
> 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?

I do not believe this is a limitation. BOOST_CHECK/WARN_NO_THROW is another
story. Problem here is I do not want to replicate the whole machinery of
identifying exception for every single assertion. I think the best policy in
this case would be to just follow TDD recommendation and place single check
per test case. No need for assertion at all, just invoke you code and
Boost.Test validates that it runs fine or reports proper error otherwise
 
Regards,
Gennadiy


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