Boost C++ Libraries

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

PrevUpHomeNext

Predefined log format selection

The select at compile time the log format from the list of the formats supplied by the Unit Test Framework

boost::unit_test::unit_test_log.set_format( boost::unit_test::output_format );

or for adding a format:

boost::unit_test::unit_test_log.add_format( boost::unit_test::output_format );
[Caution] Caution

boost::unit_test::unit_test_log_t::set_format above disables all formatters but the one provided as argument.

[Tip] Tip

See boost::unit_test::unit_test_log_t::set_format and boost::unit_test::output_format for more details

In regular circumstances you shouldn't use this interface. Prefer to use runtime parameters --log_format or --logger for predefined log format selection.

Example: Compile-time log format selection

Code

#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>
using namespace boost::unit_test;

struct MyConfig {
  MyConfig() {
    unit_test_log.set_format( OF_XML );
  }
  ~MyConfig() {}
};

BOOST_TEST_GLOBAL_CONFIGURATION( MyConfig );

BOOST_AUTO_TEST_CASE( test_case0 ) {
  BOOST_TEST( false );
}

Output

> example --report_level=no
<TestLog><Error file="test.cpp" line="23">check false failed</Error></TestLog>

PrevUpHomeNext