Is there a way to get the current error count of the current test case in Boost UTF?

I'd like to execute code in the case that at least one check in my test case failed. Something like:

 if (BOOST_ERROR_COUNT > 0) { ... }

(This macro does not exist.)

有帮助吗?

解决方案

You can access information about the current test case via the boost::unit_test::results_collector

e.g.

using boost::unit_test::results_collector;
using boost::unit_test::framework::current_test_case;
using boost::unit_test::test_case;
using boost::unit_test::test_results;

const test_results& theResults = results_collector.results( current_test_case().p_id );

This gets you a boost::unit_test::test_results which contains all of the information you are after.

See Also boost/test/results_collector.hpp

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top