3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Assertion severity level</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="../testing_tools.html" title="Writing unit tests">
9 <link rel="prev" href="../testing_tools.html" title="Writing unit tests">
10 <link rel="next" href="boost_test_universal_macro.html" title="BOOST_TEST: universal and general purpose assertions">
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>
22 <div class="spirit-nav">
23 <a accesskey="p" href="../testing_tools.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../testing_tools.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="boost_test_universal_macro.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h3 class="title">
27 <a name="boost_test.testing_tools.tools_assertion_severity_level"></a><a class="link" href="tools_assertion_severity_level.html" title="Assertion severity level">Assertion
29 </h3></div></div></div>
31 There are three <span class="bold"><strong>levels</strong></span> of assertions and
32 all the testing tools are supplied in these three flavours/levels. These
33 levels have different meaning on the consistency of the test case:
35 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
37 <code class="computeroutput"><span class="identifier">REQUIRE</span></code> which implements
38 a <span class="bold"><strong>requirements</strong></span> : this is a strong condition
39 for the operations following the assertion to be valid. This type of
40 assertions should be used when a pre-condition for running the test is
41 not met or when the test-case cannot continue. If such as assertion fails,
42 the test case execution stops immediately, and the test-case is flagged
43 as <span class="emphasis"><em>failed</em></span>.
46 <code class="computeroutput"><span class="identifier">CHECK</span></code> for standard <span class="bold"><strong>checks</strong></span>: this is the most commonly used assertion
47 level. If the statement evaluates to <code class="computeroutput"><span class="keyword">false</span></code>,
48 the test case is flagged as failed but its execution continues.
51 <code class="computeroutput"><span class="identifier">WARN</span></code> which stands for
52 <span class="bold"><strong>warnings</strong></span>: this is an assertion providing
53 information. The test case execution continues and a warning message
54 is logged. The warning does not change the success status of a test case.
55 This level of assertion can be used to validate aspects less important
56 then correctness: performance, portability, usability, etc.
62 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
64 <a class="link" href="../utf_reference/testing_tool_ref/assertion_boost_level_throw.html" title="BOOST_<level>_THROW"><code class="computeroutput"><span class="identifier">BOOST_REQUIRE_THROW</span></code></a>, <a class="link" href="../utf_reference/testing_tool_ref/assertion_boost_test_universal_macro.html" title="BOOST_TEST"><code class="computeroutput"><span class="identifier">BOOST_TEST_REQUIRE</span></code></a>
67 <code class="computeroutput"><span class="identifier">BOOST_CHECK_THROW</span></code>, <code class="computeroutput"><span class="identifier">BOOST_TEST</span></code> <a href="#ftn.boost_test.testing_tools.tools_assertion_severity_level.f0" class="footnote" name="boost_test.testing_tools.tools_assertion_severity_level.f0"><sup class="footnote">[6]</sup></a>
70 <code class="computeroutput"><span class="identifier">BOOST_WARN_THROW</span></code>, <code class="computeroutput"><span class="identifier">BOOST_TEST_WARN</span></code>
74 These three levels of assertions are filtered by the framework and reported
75 into the test log and output:
77 <div class="orderedlist"><ol class="orderedlist" type="1">
79 If an assertion designated by the tool passes, confirmation message can
80 be printed in log output <a href="#ftn.boost_test.testing_tools.tools_assertion_severity_level.f1" class="footnote" name="boost_test.testing_tools.tools_assertion_severity_level.f1"><sup class="footnote">[7]</sup></a>.
83 If an assertion designated by the tool fails, the following will happen,
84 depending on the assertion level <a href="#ftn.boost_test.testing_tools.tools_assertion_severity_level.f2" class="footnote" name="boost_test.testing_tools.tools_assertion_severity_level.f2"><sup class="footnote">[8]</sup></a>:
88 <a name="boost_test.testing_tools.tools_assertion_severity_level.assertions_severity_levels"></a><p class="title"><b>Table 3. Assertions severity levels</b></p>
89 <div class="table-contents"><table class="table" summary="Assertions severity levels">
127 warning in <code class="computeroutput"><span class="special"><</span><span class="identifier">test</span><span class="special">-</span><span class="keyword">case</span><span class="special">-</span><span class="identifier">name</span><span class="special">></span></code>: condition <code class="computeroutput"><span class="special"><</span><span class="identifier">assertion</span> <span class="identifier">description</span><span class="special">></span></code> is not satisfied
149 error in <code class="computeroutput"><span class="special"><</span><span class="identifier">test</span><span class="special">-</span><span class="keyword">case</span><span class="special">-</span><span class="identifier">name</span><span class="special">></span></code>: test <code class="computeroutput"><span class="special"><</span><span class="identifier">assertion</span> <span class="identifier">description</span><span class="special">></span></code> failed
171 fatal error in <code class="computeroutput"><span class="special"><</span><span class="identifier">test</span><span class="special">-</span><span class="keyword">case</span><span class="special">-</span><span class="identifier">name</span><span class="special">></span></code>:
172 critical test <code class="computeroutput"><span class="special"><</span><span class="identifier">assertion</span> <span class="identifier">description</span><span class="special">></span></code> failed
189 <br class="table-break"><p>
190 The granularity of the report depends on the current <a class="link" href="../utf_reference/rt_param_reference/log_level.html" title="log_level">log
191 level</a> and <a class="link" href="../utf_reference/rt_param_reference/report_level.html" title="report_level">report
194 <div class="note"><table border="0" summary="Note">
196 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
197 <th align="left">Note</th>
199 <tr><td align="left" valign="top"><p>
200 in the above table, the <span class="emphasis"><em>test execution</em></span> is related
201 to the current test case <span class="emphasis"><em>only</em></span>. Hence <span class="emphasis"><em>"aborts"</em></span>
202 means that the current test case is aborted, but other test cases in the
203 test tree are still executed.
206 <div class="footnotes">
207 <br><hr style="width:100; text-align:left;margin-left: 0">
208 <div id="ftn.boost_test.testing_tools.tools_assertion_severity_level.f0" class="footnote"><p><a href="#boost_test.testing_tools.tools_assertion_severity_level.f0" class="para"><sup class="para">[6] </sup></a>
209 <a class="link" href="../utf_reference/testing_tool_ref/assertion_boost_test_universal_macro.html" title="BOOST_TEST"><code class="computeroutput"><span class="identifier">BOOST_TEST</span></code></a> is equivalent to
210 <code class="computeroutput"><span class="identifier">BOOST_TEST_CHECK</span></code>
212 <div id="ftn.boost_test.testing_tools.tools_assertion_severity_level.f1" class="footnote"><p><a href="#boost_test.testing_tools.tools_assertion_severity_level.f1" class="para"><sup class="para">[7] </sup></a>
213 to manage what messages appear in the test log stream, set the proper
214 <a class="link" href="../utf_reference/rt_param_reference/log_level.html" title="log_level"><code class="computeroutput"><span class="identifier">log_level</span></code></a>
216 <div id="ftn.boost_test.testing_tools.tools_assertion_severity_level.f2" class="footnote"><p><a href="#boost_test.testing_tools.tools_assertion_severity_level.f2" class="para"><sup class="para">[8] </sup></a>
217 in some cases log message can be slightly different to reflect failed
218 tool specifics, see <a class="link" href="reports.html" title="Reported information">here</a>
222 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
223 <td align="left"></td>
224 <td align="right"><div class="copyright-footer">Copyright © 2001-2019 Boost.Test
226 Distributed under the Boost Software License, Version 1.0. (See accompanying
227 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>)
232 <div class="spirit-nav">
233 <a accesskey="p" href="../testing_tools.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../testing_tools.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="boost_test_universal_macro.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>