Reputation: 2283
When debugging a C++ Boost.Test application inside VS2010 (VS2008), how to make the debugger stop at Boost.Test assertion failure points?
Upvotes: 6
Views: 2626
Reputation: 4677
assertion.hpp
template class binary_expr:
assertion_result evaluate( bool no_message = false ) const
{
assertion_result const expr_res( value() );
if( no_message || expr_res )
return expr_res; <<<<<<<< SUCCESS
BRK wrap_stringstream buff;
report( buff.stream() );
return tt_detail::format_assertion_result( buff.stream().str(), expr_res.message() );
}
Upvotes: 0
Reputation: 14521
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
}
Upvotes: 2
Reputation: 24892
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).
Upvotes: 2