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.

Class test_results

boost::unit_test::test_results — Collection of attributes constituting test unit results.


// In header: <boost/test/results_collector.hpp>

class test_results {
  // construct/copy/destruct

  // public member functions
  typedef BOOST_READONLY_PROPERTY(counter_t, 
  bool passed() const;
  bool aborted() const;
  int result_code() const;
  void operator+=(test_results const &);
  void clear();

  // public data members
  counter_prop p_assertions_passed;  // Number of successful assertions. 
  counter_prop p_assertions_failed;  // Number of failing assertions. 
  counter_prop p_warnings_failed;  // Number of warnings. 
  counter_prop p_expected_failures;
  counter_prop p_test_cases_passed;  // Number of successfull test cases. 
  counter_prop p_test_cases_warned;  // Number of warnings in test cases. 
  counter_prop p_test_cases_failed;  // Number of failing test cases. 
  counter_prop p_test_cases_skipped;  // Number of skipped test cases. 
  counter_prop p_test_cases_aborted;  // Number of aborted test cases. 
  counter_prop p_duration_microseconds;  // Duration of the test in microseconds. 
  bool_prop p_aborted;  // Indicates that the test unit execution has been aborted. 
  bool_prop p_skipped;  // Indicates that the test unit execution has been skipped. 


This class is a collection of attributes describing a test result.

The attributes presented as public properties on an instance of the class. In addition summary conclusion methods are presented to generate simple answer to pass/fail question

test_results public construct/copy/destruct

  1. test_results();

test_results public member functions

  1. typedef BOOST_READONLY_PROPERTY(counter_t, 
    Type representing counter like public property.
  2. typedef BOOST_READONLY_PROPERTY(bool, 
    Type representing boolean like public property.
  3. bool passed() const;
    Returns true if test unit passed.
  4. bool aborted() const;
    Returns true if the test unit was aborted (hard failure)
  5. int result_code() const;
    Produces result code for the test unit execution.

    This methhod return one of the result codes defined in boost/cstdlib.hpp


    • boost::exit_success on success,

    • boost::exit_exception_failure in case test unit was aborted for any reason (incuding uncaught exception)

    • and boost::exit_test_failure otherwise

  6. void operator+=(test_results const &);
    Combines the results of the current instance with another.

    Only the counters are updated and the p_aborted and p_skipped are left unchanged.

  7. void clear();
    Resets the current state of the result.