Debugging Boost.Test Application

When debugging a C ++ Boost.Test application in VS2010 (VS2008), how to make the debugger stop at the Boost.Test statement error points?

+6
c ++ boost unit-testing visual-studio-2010
source share
3 answers

I have not tried this myself, but theoretically you need to set a breakpoint somewhere in the check_impl function (in boost_unit_test_library), probably in cases other than PASS, in the latter case.

In practice, I always just run the tests again (or a specific test test selected with the --run_test = ... option) with a breakpoint at the abusive check.

Note that a BOOST_REQUIRE failure results in a throw, so if you enable VS 'break-on-C ++, there are exceptions in the debugging options that will be broken into them nicely (but not BOOST_CHECK s that just return and continue).

+2
source share

I set breakpoints in check_impl() , as suggested by @timday.

Here is an excerpt 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 } 
+1
source share

assertion.hpp

binary_expr template class:

 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() ); } 
0
source share

All Articles