testing_tools.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Writing unit tests</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="../index.html" title="Boost.Test">
  9. <link rel="prev" href="tests_organization/summary_of_the_api_for_declaring.html" title="Summary of the API for declaring and organizing tests">
  10. <link rel="next" href="testing_tools/tools_assertion_severity_level.html" title="Assertion severity level">
  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="tests_organization/summary_of_the_api_for_declaring.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.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="testing_tools/tools_assertion_severity_level.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="section">
  26. <div class="titlepage"><div><div><h2 class="title" style="clear: both">
  27. <a name="boost_test.testing_tools"></a><a class="link" href="testing_tools.html" title="Writing unit tests">Writing unit tests</a>
  28. </h2></div></div></div>
  29. <div class="toc"><dl class="toc">
  30. <dt><span class="section"><a href="testing_tools/tools_assertion_severity_level.html">Assertion
  31. severity level</a></span></dt>
  32. <dt><span class="section"><a href="testing_tools/boost_test_universal_macro.html">BOOST_TEST:
  33. universal and general purpose assertions</a></span></dt>
  34. <dt><span class="section"><a href="testing_tools/reports.html">Reported information</a></span></dt>
  35. <dt><span class="section"><a href="testing_tools/extended_comparison.html">Extended
  36. comparisons support</a></span></dt>
  37. <dd><dl>
  38. <dt><span class="section"><a href="testing_tools/extended_comparison/floating_point.html">Floating
  39. point comparison</a></span></dt>
  40. <dd><dl>
  41. <dt><span class="section"><a href="testing_tools/extended_comparison/floating_point/customizing_for_tolerance.html">Enabling
  42. tolerance for user-defined types</a></span></dt>
  43. <dt><span class="section"><a href="testing_tools/extended_comparison/floating_point/floating_points_comparison_impl.html">Tolerance-based
  44. comparisons</a></span></dt>
  45. <dt><span class="section"><a href="testing_tools/extended_comparison/floating_point/floating_points_comparison_theory.html">Theory
  46. behind floating point comparisons</a></span></dt>
  47. </dl></dd>
  48. <dt><span class="section"><a href="testing_tools/extended_comparison/strings.html">Strings
  49. and C-strings comparison</a></span></dt>
  50. <dt><span class="section"><a href="testing_tools/extended_comparison/collections.html">Collections
  51. comparison</a></span></dt>
  52. <dt><span class="section"><a href="testing_tools/extended_comparison/bitwise.html">Bitwise
  53. comparison</a></span></dt>
  54. </dl></dd>
  55. <dt><span class="section"><a href="testing_tools/exception_correctness.html">Exception
  56. correctness</a></span></dt>
  57. <dt><span class="section"><a href="testing_tools/timeout.html">Time-out for test cases</a></span></dt>
  58. <dt><span class="section"><a href="testing_tools/expected_failures.html">Expected
  59. failures specification</a></span></dt>
  60. <dt><span class="section"><a href="testing_tools/custom_predicates.html">Custom predicate
  61. support</a></span></dt>
  62. <dt><span class="section"><a href="testing_tools/output_stream_testing.html">Output
  63. streams testing tool</a></span></dt>
  64. <dt><span class="section"><a href="testing_tools/internal_details.html"><code class="computeroutput"><span class="identifier">BOOST_TEST</span></code>: details on expressions</a></span></dt>
  65. <dt><span class="section"><a href="testing_tools/debugging.html">Debugging the assertions</a></span></dt>
  66. <dt><span class="section"><a href="testing_tools/summary.html">Summary of the API
  67. for writing tests</a></span></dt>
  68. </dl></div>
  69. <p>
  70. Once a test case has been declared, the body of this test should be written.
  71. A test case is a sequence of operations in which <span class="bold"><strong>assertions</strong></span>
  72. are inserted. Those assertions evaluate <span class="emphasis"><em>statements</em></span> that
  73. implement the expectation being validated, and report failures and/or information
  74. in a uniform manner, depending on the <a class="link" href="utf_reference/rt_param_reference/log_level.html" title="log_level">log
  75. level</a>.
  76. </p>
  77. <p>
  78. The <span class="emphasis"><em>Unit Test Framework</em></span>'s supplies a toolbox of assertions
  79. to ease the creation and maintenance of test cases and provide a uniform error
  80. reporting mechanism. The toolbox supplied is in most part in a form of macro
  81. declarations. An (almost) unique interface to all of them implemented by the
  82. macro <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>.
  83. </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>
  90. All macros arguments are calculated once, so it's safe to pass complex expressions
  91. in their place.
  92. </p></td></tr>
  93. </table></div>
  94. <p>
  95. All tools automatically supply an error location: a file name and a line number,
  96. which can also be overridden.
  97. </p>
  98. <div class="caution"><table border="0" summary="Caution">
  99. <tr>
  100. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../doc/src/images/caution.png"></td>
  101. <th align="left">Caution</th>
  102. </tr>
  103. <tr><td align="left" valign="top"><p>
  104. The testing tools are intended for unit test code rather than library or
  105. production code, where throwing exceptions, using <code class="computeroutput"><span class="identifier">assert</span><span class="special">()</span></code>, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">concept_check</span></code>
  106. or <code class="computeroutput"><span class="identifier">BOOST_STATIC_ASSERT</span><span class="special">()</span></code>
  107. may be more suitable ways to detect and report errors.
  108. </p></td></tr>
  109. </table></div>
  110. <p>
  111. For a list of all supplied testing tools and usage examples, see the <a class="link" href="testing_tools/summary.html" title="Summary of the API for writing tests">summary</a> or the <a class="link" href="utf_reference/testing_tool_ref.html" title="Reference API for writing tests">reference</a>.
  112. </p>
  113. </div>
  114. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  115. <td align="left"></td>
  116. <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2019 Boost.Test
  117. 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="tests_organization/summary_of_the_api_for_declaring.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.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="testing_tools/tools_assertion_severity_level.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  126. </div>
  127. </body>
  128. </html>