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 for the latest Boost documentation.

Custom messages

The macro BOOST_TEST_MESSAGE is intended to be used for the purpose of injecting an additional message into the Unit Test Framework test log. These messages are not intended to indicate any error or warning conditions, but rather as information/status notifications. The macro signature is as follows:


The test_message argument can be as simple as C string literal or any custom expression that you can produce with in a manner similar to standard std::iostream operation.

[Important] Important

Messages generated by this tool do not appear in test log output with default value of the active log level threshold. For these messages to appear the active log level threshold has to be set to a value below or equal to "message".



#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>

  int current_time = 0; // real call is required here

  BOOST_TEST_MESSAGE( "Testing initialization :" );
  BOOST_TEST_MESSAGE( "Current time:" << current_time );

BOOST_AUTO_TEST_CASE( test_update )
  std::string field_name = "Volume";
  int         value      = 100;

  BOOST_TEST_MESSAGE( "Testing update :" );
  BOOST_TEST_MESSAGE( "Update " << field_name << " with " << value );


> example --log_level=message
Running 2 test cases...
Testing initialization :
Current time:0
Testing update :
Update Volume with 100

*** No errors detected