在VS2010 (VS2008)中调试C++ Boost.Test应用程序时,如何使调试器在Boost.Test断言故障点处停止?
发布于 2010-08-15 23:31:34
我自己还没有尝试过,但理论上您可能希望在check_impl function中的某个地方(在boost_unit_test_library源代码中)设置一个断点,可能是在其最后一条case语句的未通过情况下。
实际上,我总是发现自己只是再次运行测试(或使用--run_ test =...选择的特定问题测试)。在有问题的检查上有断点。
请注意,失败的BOOST_REQUIRE会导致抛出异常,所以如果您在调试选项中启用了VS‘break- on -C++-exceptions’,这些异常就会很好地中断(而不是BOOST_CHECK,它只会返回并继续)。
发布于 2015-05-12 19:58:16
正如@timday所建议的那样,我在check_impl()中设置了断点。
以下是Boost 1.57.0文件boost/test/impl/test_tool.ipp第355到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
}发布于 2017-11-11 22:20:04
assertion.hpp
模板类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() );
}https://stackoverflow.com/questions/3486929
复制相似问题