...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
In case if the test module involves lengthy computation split among multiple test cases you may be interested in progress monitor. The test runners supplied with the Unit Test Framework support simple text progress display, implemented based on
boost::progress_display
[17].
The progress display output is enabled using the Unit Test Framework
parameter show_progress
.
The Unit Test Framework has no ability to estimate how long (in time duration) the test case execution is going to take and the manual test progress update is not supported at this point. The Unit Test Framework tracks the progress on test case level. If you want to see more frequent progress update, you need to split the test into multiple test cases.
In default configuration both test log and test progress outputs are directed into standard output stream. Any test log messages are going to interfere with test progress display. To prevent this you can either set log level to lower level or redirect either test log or test progress output into different stream during test module initialization. Use following interface to redirect test progress output:
boost::unit_test::progress_monitor.set_stream( std::ostream& )
Code |
---|
#define BOOST_TEST_MODULE example49 #include <boost/test/included/unit_test.hpp> #include <boost/test/data/test_case.hpp> using namespace boost::unit_test; BOOST_DATA_TEST_CASE( free_test_function, boost::unit_test::data::xrange(1000) ) { // sleep(1); BOOST_TEST( true /* test assertion */ ); } |
Output |
---|
> example --show_progress=yes --log_level=nothing 0% 10 20 30 40 50 60 70 80 90 100% |----|----|----|----|----|----|----|----|----|----| *************************************************** *** No errors detected |
[17] The Unit Test Framework interfaces allow implementing an advanced GUI based test runner with arbitrary progress display controls