• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
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 — 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
34</span>
35<span class="keyword">class</span> <a class="link" href="test_observer.html" title="Class test_observer">test_observer</a> <span class="special">{</span>
36<span class="keyword">public</span><span class="special">:</span>
37  <span class="comment">// <a class="link" href="test_observer.html#boost.unit_test.test_observerconstruct-copy-destruct">construct/copy/destruct</a></span>
38  <a class="link" href="test_observer.html#idm45267286911296-bb"><span class="special">~</span><span class="identifier">test_observer</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
39
40  <span class="comment">// <a class="link" href="test_observer.html#idm45267286947264-bb">public member functions</a></span>
41  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm45267286946704-bb"><span class="identifier">test_start</span></a><span class="special">(</span><span class="identifier">counter_t</span><span class="special">,</span> <span class="identifier">test_unit_id</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#idm45267286943456-bb"><span class="identifier">test_finish</span></a><span class="special">(</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#idm45267286940976-bb"><span class="identifier">test_aborted</span></a><span class="special">(</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#idm45267286938000-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>
45  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm45267286935152-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>
46  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm45267286931648-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>
47  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm45267286928864-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>
48  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm45267286926480-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>
49  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm45267286923520-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>
50  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm45267286918512-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>
51  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="test_observer.html#idm45267286916688-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>
52  <span class="keyword">virtual</span> <span class="keyword">int</span> <a class="link" href="test_observer.html#idm45267286913728-bb"><span class="identifier">priority</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
53<span class="special">}</span><span class="special">;</span></pre></div>
54<div class="refsect1">
55<a name="idm46175615782848"></a><h2>Description</h2>
56<p>This interface is used by observers in order to receive notifications from the Boost.Test framework on the current execution state.</p>
57<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>
58<div class="refsect2">
59<a name="idm46175615781488"></a><h3>
60<a name="boost.unit_test.test_observerconstruct-copy-destruct"></a><code class="computeroutput">test_observer</code>
61        public
62       construct/copy/destruct</h3>
63<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><a name="idm45267286911296-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>
64</div>
65<div class="refsect2">
66<a name="idm46175615775152"></a><h3>
67<a name="idm45267286947264-bb"></a><code class="computeroutput">test_observer</code> public member functions</h3>
68<div class="orderedlist"><ol class="orderedlist" type="1">
69<li class="listitem">
70<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286946704-bb"></a><span class="identifier">test_start</span><span class="special">(</span><span class="identifier">counter_t</span><span class="special">,</span> <span class="identifier">test_unit_id</span><span class="special">)</span><span class="special">;</span></pre>Called before the framework starts executing the test cases. <p>
71</p>
72</li>
73<li class="listitem">
74<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286943456-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">
75<tr>
76<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
77<th align="left">Note</th>
78</tr>
79<tr><td align="left" valign="top"><p>The call is made with a reversed priority order. </p></td></tr>
80</table></div>
81<p>
82</p>
83</li>
84<li class="listitem">
85<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286940976-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>
86<div class="note"><table border="0" summary="Note">
87<tr>
88<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
89<th align="left">Note</th>
90</tr>
91<tr><td align="left" valign="top"><p>may be called before test_observer::test_unit_finish() </p></td></tr>
92</table></div>
93<p>
94</p>
95</li>
96<li class="listitem">
97<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286938000-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>
98</p>
99</li>
100<li class="listitem">
101<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286935152-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>
102</p>
103</li>
104<li class="listitem"><pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286931648-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>
105<li class="listitem">
106<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286928864-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>
107<li class="listitem">
108<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286926480-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>
109</li>
110<li class="listitem">
111<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286923520-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>
112<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
113<li class="listitem"><p>a strong assertion (with <code class="computeroutput">REQUIRE</code>) fails, which indicates that the test case cannot continue</p></li>
114<li class="listitem"><p>an unexpected exception is caught by the Boost.Test framework </p></li>
115</ul></div>
116<p>
117</p>
118</li>
119<li class="listitem"><pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286918512-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>
120<li class="listitem">
121<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm45267286916688-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>
122</li>
123<li class="listitem">
124<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">int</span> <a name="idm45267286913728-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>
125</ol></div>
126</div>
127</div>
128</div>
129<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
130<td align="left"></td>
131<td align="right"><div class="copyright-footer">Copyright © 2001-2020 Boost.Test contributors<p>
132        Distributed under the Boost Software License, Version 1.0. (See accompanying
133        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>)
134      </p>
135</div></td>
136</tr></table>
137<hr>
138<div class="spirit-nav">
139<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>
140</div>
141</body>
142</html>
143