|
||||
File indexing completed on 2024-11-15 09:32:32
0001 // (C) Copyright Gennadiy Rozental 2001. 0002 // Distributed under the Boost Software License, Version 1.0. 0003 // (See accompanying file LICENSE_1_0.txt or copy at 0004 // http://www.boost.org/LICENSE_1_0.txt) 0005 0006 // See http://www.boost.org/libs/test for the library home page. 0007 // 0008 /// @file 0009 /// @brief Defines testing result collector components 0010 /// 0011 /// Defines classes for keeping track (@ref test_results) and collecting 0012 /// (@ref results_collector_t) the states of the test units. 0013 // *************************************************************************** 0014 0015 #ifndef BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER 0016 #define BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER 0017 0018 // Boost.Test 0019 #include <boost/test/tree/observer.hpp> 0020 0021 #include <boost/test/detail/global_typedef.hpp> 0022 #include <boost/test/detail/fwd_decl.hpp> 0023 0024 #include <boost/test/utils/class_properties.hpp> 0025 0026 #include <boost/test/detail/suppress_warnings.hpp> 0027 0028 //____________________________________________________________________________// 0029 0030 namespace boost { 0031 namespace unit_test { 0032 0033 namespace { 0034 0035 // ************************************************************************** // 0036 /// First failed assertion debugger hook 0037 /// 0038 /// This function is a placeholder where user can set a breakpoint in debugger to catch the 0039 /// very first assertion failure in each test case 0040 // ************************************************************************** // 0041 inline void first_failed_assertion() {} 0042 } 0043 0044 // ************************************************************************** // 0045 /// @brief Collection of attributes constituting test unit results 0046 /// 0047 /// This class is a collection of attributes describing a test result. 0048 /// 0049 /// The attributes presented as public properties on 0050 /// an instance of the class. In addition summary conclusion methods are presented to generate simple answer to pass/fail question 0051 0052 class BOOST_TEST_DECL test_results { 0053 public: 0054 test_results(); 0055 0056 /// Type representing counter like public property 0057 typedef BOOST_READONLY_PROPERTY( counter_t, (results_collector_t) 0058 (test_results) 0059 (results_collect_helper) ) counter_prop; 0060 /// Type representing boolean like public property 0061 typedef BOOST_READONLY_PROPERTY( bool, (results_collector_t) 0062 (test_results) 0063 (results_collect_helper) ) bool_prop; 0064 0065 counter_prop p_test_suites; //!< Number of test suites 0066 counter_prop p_assertions_passed; //!< Number of successful assertions 0067 counter_prop p_assertions_failed; //!< Number of failing assertions 0068 counter_prop p_warnings_failed; //!< Number of warnings 0069 counter_prop p_expected_failures; 0070 counter_prop p_test_cases_passed; //!< Number of successfull test cases 0071 counter_prop p_test_cases_warned; //!< Number of warnings in test cases 0072 counter_prop p_test_cases_failed; //!< Number of failing test cases 0073 counter_prop p_test_cases_skipped; //!< Number of skipped test cases 0074 counter_prop p_test_cases_aborted; //!< Number of aborted test cases 0075 counter_prop p_test_cases_timed_out; //!< Number of timed out test cases 0076 counter_prop p_test_suites_timed_out; //!< Number of timed out test suites 0077 counter_prop p_duration_microseconds; //!< Duration of the test in microseconds 0078 bool_prop p_aborted; //!< Indicates that the test unit execution has been aborted 0079 bool_prop p_skipped; //!< Indicates that the test unit execution has been skipped 0080 bool_prop p_timed_out; //!< Indicates that the test unit has timed out 0081 0082 /// Returns true if test unit passed 0083 bool passed() const; 0084 0085 /// Returns true if test unit skipped 0086 /// 0087 /// For test suites, this indicates if the test suite itself has been marked as 0088 /// skipped, and not if the test suite contains any skipped test. 0089 bool skipped() const; 0090 0091 /// Returns true if the test unit was aborted (hard failure) 0092 bool aborted() const; 0093 0094 /// Produces result code for the test unit execution 0095 /// 0096 /// This methhod return one of the result codes defined in @c boost/cstdlib.hpp 0097 /// @returns 0098 /// - @c boost::exit_success on success, 0099 /// - @c boost::exit_exception_failure in case test unit 0100 /// was aborted for any reason (including uncaught exception) 0101 /// - and @c boost::exit_test_failure otherwise 0102 int result_code() const; 0103 0104 //! Combines the results of the current instance with another 0105 //! 0106 //! Only the counters are updated and the @c p_aborted and @c p_skipped are left unchanged. 0107 void operator+=( test_results const& ); 0108 0109 //! Resets the current state of the result 0110 void clear(); 0111 }; 0112 0113 // ************************************************************************** // 0114 /// @brief Collects and combines the test results 0115 /// 0116 /// This class collects and combines the results of the test unit during the execution of the 0117 /// test tree. The results_collector_t::results() function combines the test results on a subtree 0118 /// of the test tree. 0119 /// 0120 /// @see boost::unit_test::test_observer 0121 class BOOST_TEST_DECL results_collector_t : public test_observer { 0122 public: 0123 0124 void test_start( counter_t, test_unit_id ) BOOST_OVERRIDE; 0125 0126 void test_unit_start( test_unit const& ) BOOST_OVERRIDE; 0127 void test_unit_finish( test_unit const&, unsigned long ) BOOST_OVERRIDE; 0128 void test_unit_skipped( test_unit const&, const_string ) BOOST_OVERRIDE; 0129 void test_unit_aborted( test_unit const& ) BOOST_OVERRIDE; 0130 void test_unit_timed_out( test_unit const& ) BOOST_OVERRIDE; 0131 0132 void assertion_result( unit_test::assertion_result ) BOOST_OVERRIDE; 0133 void exception_caught( execution_exception const& ) BOOST_OVERRIDE; 0134 0135 int priority() BOOST_OVERRIDE { return 3; } 0136 0137 /// Results access per test unit 0138 /// 0139 /// @param[in] tu_id id of a test unit 0140 test_results const& results( test_unit_id tu_id ) const; 0141 0142 /// Singleton pattern 0143 BOOST_TEST_SINGLETON_CONS( results_collector_t ) 0144 }; 0145 0146 BOOST_TEST_SINGLETON_INST( results_collector ) 0147 0148 } // namespace unit_test 0149 } // namespace boost 0150 0151 #include <boost/test/detail/enable_warnings.hpp> 0152 0153 #endif // BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |