test_output_progress.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  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. <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>
  81. <span class="special">{</span>
  82. <span class="comment">// sleep(1);</span>
  83. <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>
  84. <span class="special">}</span>
  85. </pre>
  86. </td></tr></tbody>
  87. </table></div>
  88. <div class="informaltable"><table class="table">
  89. <colgroup><col></colgroup>
  90. <thead><tr><th>
  91. <p>
  92. Output
  93. </p>
  94. </th></tr></thead>
  95. <tbody><tr><td>
  96. <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>
  97. <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>
  98. <span class="special">|----|----|----|----|----|----|----|----|----|----|</span>
  99. <span class="special">***************************************************</span>
  100. <span class="special">***</span> <span class="identifier">No</span> <span class="identifier">errors</span> <span class="identifier">detected</span>
  101. </pre>
  102. </td></tr></tbody>
  103. </table></div>
  104. <div class="footnotes">
  105. <br><hr style="width:100; text-align:left;margin-left: 0">
  106. <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>
  107. The <span class="emphasis"><em>Unit Test Framework</em></span> interfaces allow implementing
  108. an advanced GUI based test runner with arbitrary progress display controls
  109. </p></div>
  110. </div>
  111. </div>
  112. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  113. <td align="left"></td>
  114. <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2019 Boost.Test
  115. contributors<p>
  116. Distributed under the Boost Software License, Version 1.0. (See accompanying
  117. 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>)
  118. </p>
  119. </div></td>
  120. </tr></table>
  121. <hr>
  122. <div class="spirit-nav">
  123. <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>
  124. </div>
  125. </body>
  126. </html>