• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Progress display</title>
5<link rel="stylesheet" href="../../boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../index.html" title="Boost.Test">
8<link rel="up" href="../test_output.html" title="Controlling outputs">
9<link rel="prev" href="logging_api/custom_log_formatter.html" title="Custom log format support">
10<link rel="next" href="summary.html" title="Summary of the API for controlling the output">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="logging_api/custom_log_formatter.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../test_output.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="summary.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="boost_test.test_output.test_output_progress"></a><a class="link" href="test_output_progress.html" title="Progress display">Progress
28      display</a>
29</h3></div></div></div>
30<p>
31        In case if the test module involves lengthy computation split among multiple
32        test cases you may be interested in progress monitor. The test runners supplied
33        with the <span class="emphasis"><em>Unit Test Framework</em></span> support simple text progress
34        display, implemented based on
35      </p>
36<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">progress_display</span>
37</pre>
38<p>
39        <a href="#ftn.boost_test.test_output.test_output_progress.f0" class="footnote" name="boost_test.test_output.test_output_progress.f0"><sup class="footnote">[17]</sup></a>.
40      </p>
41<p>
42        The progress display output is enabled using the <span class="emphasis"><em>Unit Test Framework</em></span>
43        parameter <a class="link" href="../utf_reference/rt_param_reference/show_progress.html" title="show_progress"><code class="computeroutput"><span class="identifier">show_progress</span></code></a>.
44      </p>
45<p>
46        The <span class="emphasis"><em>Unit Test Framework</em></span> has no ability to estimate how
47        long (in time duration) the test case execution is going to take and the
48        manual test progress update is not supported at this point. The <span class="emphasis"><em>Unit
49        Test Framework</em></span> tracks the progress on test case level. If you
50        want to see more frequent progress update, you need to split the test into
51        multiple test cases.
52      </p>
53<p>
54        In default configuration both test log and test progress outputs are directed
55        into standard output stream. Any test log messages are going to interfere
56        with test progress display. To prevent this you can either set log level
57        to lower level or redirect either test log or test progress output into different
58        stream during test module initialization. Use following interface to redirect
59        test progress output:
60      </p>
61<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">progress_monitor</span><span class="special">.</span><span class="identifier">set_stream</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&amp;</span> <span class="special">)</span>
62</pre>
63<h6>
64<a name="boost_test.test_output.test_output_progress.h0"></a>
65        <span class="phrase"><a name="boost_test.test_output.test_output_progress.example_descr"></a></span><a class="link" href="test_output_progress.html#boost_test.test_output.test_output_progress.example_descr">Example:
66        Progress report for the test module with large amount of test cases</a>
67      </h6>
68<div class="informaltable"><table class="table">
69<colgroup><col></colgroup>
70<thead><tr><th>
71                <p>
72                  Code
73                </p>
74              </th></tr></thead>
75<tbody><tr><td>
76<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_MODULE</span> <span class="identifier">example49</span>
77<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">included</span><span class="special">/</span><span class="identifier">unit_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
78<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">data</span><span class="special">/</span><span class="identifier">test_case</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
79<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">;</span>
80
81<span class="identifier">BOOST_DATA_TEST_CASE</span><span class="special">(</span> <span class="identifier">free_test_function</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">data</span><span class="special">::</span><span class="identifier">xrange</span><span class="special">(</span><span class="number">1000</span><span class="special">)</span> <span class="special">)</span>
82<span class="special">{</span>
83  <span class="comment">// sleep(1);</span>
84  <span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="keyword">true</span> <span class="comment">/* test assertion */</span> <span class="special">);</span>
85<span class="special">}</span>
86</pre>
87              </td></tr></tbody>
88</table></div>
89<div class="informaltable"><table class="table">
90<colgroup><col></colgroup>
91<thead><tr><th>
92                <p>
93                  Output
94                </p>
95              </th></tr></thead>
96<tbody><tr><td>
97<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">&gt;</span> <span class="identifier">example</span> <span class="special">--</span><span class="identifier">show_progress</span><span class="special">=</span><span class="identifier">yes</span> <span class="special">--</span><span class="identifier">log_level</span><span class="special">=</span><span class="identifier">nothing</span>
98
99<span class="number">0</span><span class="special">%</span>   <span class="number">10</span>   <span class="number">20</span>   <span class="number">30</span>   <span class="number">40</span>   <span class="number">50</span>   <span class="number">60</span>   <span class="number">70</span>   <span class="number">80</span>   <span class="number">90</span>   <span class="number">100</span><span class="special">%</span>
100<span class="special">|----|----|----|----|----|----|----|----|----|----|</span>
101<span class="special">***************************************************</span>
102
103<span class="special">***</span> <span class="identifier">No</span> <span class="identifier">errors</span> <span class="identifier">detected</span>
104</pre>
105              </td></tr></tbody>
106</table></div>
107<div class="footnotes">
108<br><hr style="width:100; text-align:left;margin-left: 0">
109<div id="ftn.boost_test.test_output.test_output_progress.f0" class="footnote"><p><a href="#boost_test.test_output.test_output_progress.f0" class="para"><sup class="para">[17] </sup></a>
110          The <span class="emphasis"><em>Unit Test Framework</em></span> interfaces allow implementing
111          an advanced GUI based test runner with arbitrary progress display controls
112        </p></div>
113</div>
114</div>
115<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
116<td align="left"></td>
117<td align="right"><div class="copyright-footer">Copyright © 2001-2020 Boost.Test contributors<p>
118        Distributed under the Boost Software License, Version 1.0. (See accompanying
119        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
120      </p>
121</div></td>
122</tr></table>
123<hr>
124<div class="spirit-nav">
125<a accesskey="p" href="logging_api/custom_log_formatter.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../test_output.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="summary.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
126</div>
127</body>
128</html>
129