When debugging a C++ Boost.Test application inside VS2010 (VS2008), how to make the debugger stop at Boost.Test assertion failure points?
I haven't tried this myself, but in theory you'd want to set a breakpoint somewhere in the check_impl function (in the boost_unit_test_library source), probably in the non-PASS cases of its final case statement.
In practice I always just find myself just running the tests again (or the specific problem test, selected with --run_test=...) with a breakpoint on the offending check.
Note that a failing BOOST_REQUIRE
results in a throw, so if you enable VS' break-on-C++-exceptions in the debugging options that'll break on those nicely (but not BOOST_CHECK
s, which just return and carry on).
I put breakpoints in check_impl()
, as suggested by @timday.
Here is an extract from Boost 1.57.0, file boost/test/impl/test_tool.ipp
, lines 355 to 373:
switch( tl ) {
case PASS:
framework::assertion_result( true );
return true;
case WARN:
return false; // ADD BREAKPOINT HERE
case CHECK:
framework::assertion_result( false );
return false; // ADD BREAKPOINT HERE
case REQUIRE:
framework::assertion_result( false );
framework::test_unit_aborted( framework::current_test_case() );
throw execution_aborted(); // ADD BREAKPOINT HERE
}
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