test_observer.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Class test_observer</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="../../header/boost/test/tree/observer_hpp.html" title="Header &lt;boost/test/tree/observer.hpp&gt;">
  9. <link rel="prev" href="../../header/boost/test/tree/observer_hpp.html" title="Header &lt;boost/test/tree/observer.hpp&gt;">
  10. <link rel="next" href="../../header/boost/test/tree/test_unit_hpp.html" title="Header &lt;boost/test/tree/test_unit.hpp&gt;">
  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="../../header/boost/test/tree/observer_hpp.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../header/boost/test/tree/observer_hpp.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="../../header/boost/test/tree/test_unit_hpp.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="refentry">
  26. <a name="boost.unit_test.test_observer"></a><div class="titlepage"></div>
  27. <div class="refnamediv">
  28. <h2><span class="refentrytitle">Class test_observer</span></h2>
  29. <p>boost::unit_test::test_observer &#8212; Generic test observer interface. </p>
  30. </div>
  31. <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
  32. <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../header/boost/test/tree/observer_hpp.html" title="Header &lt;boost/test/tree/observer.hpp&gt;">boost/test/tree/observer.hpp</a>&gt;
  33. </span>
  34. <span class="keyword">class</span> <a class="link" href="test_observer.html" title="Class test_observer">test_observer</a> <span class="special">{</span>
  35. <span class="keyword">public</span><span class="special">:</span>
  36. <span class="comment">// <a class="link" href="test_observer.html#boost.unit_test.test_observerconstruct-copy-destruct">construct/copy/destruct</a></span>
  37. <a class="link" href="test_observer.html#idm46279113030432-bb"><span class="special">~</span><span class="identifier">test_observer</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  38. <span class="comment">// <a class="link" href="test_observer.html#idm46279113065712-bb">public member functions</a></span>
  39. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113065152-bb"><span class="identifier">test_start</span></a><span class="special">(</span><span class="identifier">counter_t</span><span class="special">)</span><span class="special">;</span>
  40. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113062592-bb"><span class="identifier">test_finish</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  41. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113060112-bb"><span class="identifier">test_aborted</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  42. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113057136-bb"><span class="identifier">test_unit_start</span></a><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  43. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113054288-bb"><span class="identifier">test_unit_finish</span></a><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">long</span><span class="special">)</span><span class="special">;</span>
  44. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113050784-bb"><span class="identifier">test_unit_skipped</span></a><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">const_string</span><span class="special">)</span><span class="special">;</span>
  45. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113048000-bb"><span class="identifier">test_unit_skipped</span></a><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  46. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113045616-bb"><span class="identifier">test_unit_timed_out</span></a><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  47. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113042656-bb"><span class="identifier">test_unit_aborted</span></a><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  48. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113037648-bb"><span class="identifier">assertion_result</span></a><span class="special">(</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">assertion_result</span><span class="special">)</span><span class="special">;</span>
  49. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm46279113035824-bb"><span class="identifier">exception_caught</span></a><span class="special">(</span><a class="link" href="../execution_exception.html" title="Class execution_exception">execution_exception</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  50. <span class="keyword">virtual</span> <span class="keyword">int</span> <a class="link" href="test_observer.html#idm46279113032864-bb"><span class="identifier">priority</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  51. <span class="special">}</span><span class="special">;</span></pre></div>
  52. <div class="refsect1">
  53. <a name="idm45313886428368"></a><h2>Description</h2>
  54. <p>This interface is used by observers in order to receive notifications from the Boost.Test framework on the current execution state.</p>
  55. <p>Several observers can be running at the same time, and it is not unusual to have interactions among them. The test_observer::priority member function allows the specification of a particular order among them (lowest priority executed first, except specified otherwise). </p>
  56. <div class="refsect2">
  57. <a name="idm45313886427008"></a><h3>
  58. <a name="boost.unit_test.test_observerconstruct-copy-destruct"></a><code class="computeroutput">test_observer</code>
  59. public
  60. construct/copy/destruct</h3>
  61. <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><a name="idm46279113030432-bb"></a><span class="special">~</span><span class="identifier">test_observer</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li></ol></div>
  62. </div>
  63. <div class="refsect2">
  64. <a name="idm45313886420672"></a><h3>
  65. <a name="idm46279113065712-bb"></a><code class="computeroutput">test_observer</code> public member functions</h3>
  66. <div class="orderedlist"><ol class="orderedlist" type="1">
  67. <li class="listitem">
  68. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113065152-bb"></a><span class="identifier">test_start</span><span class="special">(</span><span class="identifier">counter_t</span><span class="special">)</span><span class="special">;</span></pre>Called before the framework starts executing the test cases. <p>
  69. </p>
  70. </li>
  71. <li class="listitem">
  72. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113062592-bb"></a><span class="identifier">test_finish</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Called after the framework ends executing the test cases. <div class="note"><table border="0" summary="Note">
  73. <tr>
  74. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
  75. <th align="left">Note</th>
  76. </tr>
  77. <tr><td align="left" valign="top"><p>The call is made with a reversed priority order. </p></td></tr>
  78. </table></div>
  79. <p>
  80. </p>
  81. </li>
  82. <li class="listitem">
  83. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113060112-bb"></a><span class="identifier">test_aborted</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Called when a critical error is detected. <p>The critical errors are mainly the signals sent by the system and caught by the Boost.Test framework. Since the running binary may be in incoherent/instable state, the test execution is aborted and all remaining tests are discarded.</p>
  84. <div class="note"><table border="0" summary="Note">
  85. <tr>
  86. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
  87. <th align="left">Note</th>
  88. </tr>
  89. <tr><td align="left" valign="top"><p>may be called before test_observer::test_unit_finish() </p></td></tr>
  90. </table></div>
  91. <p>
  92. </p>
  93. </li>
  94. <li class="listitem">
  95. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113057136-bb"></a><span class="identifier">test_unit_start</span><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span></pre>Called before the framework starts executing a test unit. <p>
  96. </p>
  97. </li>
  98. <li class="listitem">
  99. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113054288-bb"></a><span class="identifier">test_unit_finish</span><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">long</span><span class="special">)</span><span class="special">;</span></pre>Called at each end of a test unit. <p>
  100. </p>
  101. </li>
  102. <li class="listitem"><pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113050784-bb"></a><span class="identifier">test_unit_skipped</span><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span> tu<span class="special">,</span> <span class="identifier">const_string</span><span class="special">)</span><span class="special">;</span></pre></li>
  103. <li class="listitem">
  104. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113048000-bb"></a><span class="identifier">test_unit_skipped</span><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span></pre>backward compatibility </li>
  105. <li class="listitem">
  106. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113045616-bb"></a><span class="identifier">test_unit_timed_out</span><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span></pre>Called when the test timed out. <p>This function is called to signal that a test unit (case or suite) timed out. A valid test unit is available through boost::unit_test::framework::current_test_unit </p>
  107. </li>
  108. <li class="listitem">
  109. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113042656-bb"></a><span class="identifier">test_unit_aborted</span><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span></pre>Called when a test unit indicates a fatal error. <p>A fatal error happens when</p>
  110. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
  111. <li class="listitem"><p>a strong assertion (with <code class="computeroutput">REQUIRE</code>) fails, which indicates that the test case cannot continue</p></li>
  112. <li class="listitem"><p>an unexpected exception is caught by the Boost.Test framework </p></li>
  113. </ul></div>
  114. <p>
  115. </p>
  116. </li>
  117. <li class="listitem"><pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113037648-bb"></a><span class="identifier">assertion_result</span><span class="special">(</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">assertion_result</span><span class="special">)</span><span class="special">;</span></pre></li>
  118. <li class="listitem">
  119. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113035824-bb"></a><span class="identifier">exception_caught</span><span class="special">(</span><a class="link" href="../execution_exception.html" title="Class execution_exception">execution_exception</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span></pre>Called when an exception is intercepted. <p>In case an exception is intercepted, this call happens before the call to test_unit_aborted in order to log additional data about the exception. </p>
  120. </li>
  121. <li class="listitem">
  122. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">int</span> <a name="idm46279113032864-bb"></a><span class="identifier">priority</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>The priority indicates the order at which this observer is initialized and tore down in the UTF framework. The order is lowest to highest priority. </li>
  123. </ol></div>
  124. </div>
  125. </div>
  126. </div>
  127. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  128. <td align="left"></td>
  129. <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2019 Boost.Test
  130. contributors<p>
  131. Distributed under the Boost Software License, Version 1.0. (See accompanying
  132. 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>)
  133. </p>
  134. </div></td>
  135. </tr></table>
  136. <hr>
  137. <div class="spirit-nav">
  138. <a accesskey="p" href="../../header/boost/test/tree/observer_hpp.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../header/boost/test/tree/observer_hpp.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="../../header/boost/test/tree/test_unit_hpp.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  139. </div>
  140. </body>
  141. </html>