Home > The Unit Test Framework > User's guide > Test Output > Progress display
PrevNext

Test progress display

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 UTF support simple text progress display, implemented based on boost::progress_display[5]. The progress display output is enabled using the UTF parameter show_progress.
如果測試模塊包含大量的計算,並拆分到多個測試用例中,你可能會對進度監視感興趣。 UTF 提供的測試運行器提供簡單的文本進度顯示,基於 boost::progress_display[5] 實現。 使用 UTF 參數 show_progress 啟用進度顯示輸出。

The UTF has no ability to estimate how long the test case execution is going to take and the manual test progress update is not supported at this point. The UTF 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.
UTF 不能預測測試用例會執行多久,現在也不支持手動更新測試進度。 UTF 在測試用例級別跟蹤進度。 所以如果想要看到更頻繁的進度更新,需要將測試拆分為多個測試用例。

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& )

Example 33. Progress report for the test module with large amount of test cases

#include <boost/test/included/unit_test.hpp>
using namespace boost::unit_test;

//____________________________________________________________________________//

void free_test_function()
{
    BOOST_CHECK( true /* test assertion */ );
}

//____________________________________________________________________________//

test_suite*
init_unit_test_suite( int argc, char* argv[] ) 
{
    for( int i=0; i < 10000; i++ )
        framework::master_test_suite().
            add( BOOST_TEST_CASE( &free_test_function ) );

    return 0;
}

//____________________________________________________________________________//
Source code | Show output
> example --show_progress=yes --log_level=nothing

0%   10   20   30   40   50   60   70   80   90   100%
|----|----|----|----|----|----|----|----|----|----|
***************************************************

*** No errors detected



[5] UTF

PrevUpHomeNext