Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Adding semantic to a test

It is sometimes useful to add a semantic description to a test unit, which may be consulted by the user during a dry run. The user may then choose the test he/she wants to run based on this information, instead of basing his/her choice on the test unit name, or instead of looking at the code.

The Unit Test Framework provides the decorator description for that purpose.

Decorator description attaches an arbitrary string to the test unit. All strings attached to test units can be displayed when running a test program with parameter list_content. This can be used for conveying information from the person who composes the test tree to the person who will be running the test program. Applying more than one decorator description to the same test unit means that the two (or more) strings will be concatenated.

Example: decorator description


#define BOOST_TEST_MODULE decorator_09
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;

  * utf::disabled()
  * utf::description("enable only when ODBC is available"))
  BOOST_TEST(1 == 1);

  * utf::description("descriptions ")
  * utf::description("add up"))
  BOOST_TEST(2 == 2);


> decorator_09 --list_content
test_1 : enable only when ODBC is available
test_2*: descriptions add up