Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/test/tree/observer.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 abstract interface for test observer
0010 // ***************************************************************************
0011 
0012 #ifndef BOOST_TEST_TEST_OBSERVER_HPP_021005GER
0013 #define BOOST_TEST_TEST_OBSERVER_HPP_021005GER
0014 
0015 // Boost.Test
0016 #include <boost/test/detail/fwd_decl.hpp>
0017 #include <boost/test/detail/global_typedef.hpp>
0018 #include <boost/test/detail/config.hpp>
0019 
0020 #include <boost/test/detail/suppress_warnings.hpp>
0021 
0022 //____________________________________________________________________________//
0023 
0024 namespace boost {
0025 namespace unit_test {
0026 
0027 // ************************************************************************** //
0028 // **************                 test_observer                ************** //
0029 // ************************************************************************** //
0030 
0031 /// @brief Generic test observer interface
0032 ///
0033 /// This interface is used by observers in order to receive notifications from the
0034 /// Boost.Test framework on the current execution state.
0035 ///
0036 /// Several observers can be running at the same time, and it is not unusual to
0037 /// have interactions among them. The @ref test_observer::priority member function allows the specification
0038 /// of a particular order among them (lowest priority executed first, except specified otherwise).
0039 ///
0040 class BOOST_TEST_DECL test_observer {
0041 public:
0042 
0043     //! Called before the framework starts executing the test cases
0044     //!
0045     //! @param[in] number_of_test_cases indicates the number of test cases. Only active
0046     //! test cases are taken into account.
0047     //! @param[in] root_test_unit_id the ID root of the test tree currently being tested
0048     virtual void    test_start( counter_t /* number_of_test_cases */, test_unit_id /* root_test_unit_id */ ) {}
0049 
0050     //! Called after the framework ends executing the test cases
0051     //!
0052     //! @note The call is made with a reversed priority order.
0053     virtual void    test_finish() {}
0054 
0055     //! Called when a critical error is detected
0056     //!
0057     //! The critical errors are mainly the signals sent by the system and caught by the Boost.Test framework.
0058     //! Since the running binary may be in incoherent/instable state, the test execution is aborted and all remaining
0059     //! tests are discarded.
0060     //!
0061     //! @note may be called before test_observer::test_unit_finish()
0062     virtual void    test_aborted() {}
0063 
0064     //! Called before the framework starts executing a test unit
0065     //!
0066     //! @param[in] test_unit the test being executed
0067     virtual void    test_unit_start( test_unit const& /* test */) {}
0068 
0069     //! Called at each end of a test unit.
0070     //!
0071     //! @param elapsed duration of the test unit in microseconds.
0072     virtual void    test_unit_finish( test_unit const& /* test */, unsigned long /* elapsed */ ) {}
0073     virtual void    test_unit_skipped( test_unit const& tu, const_string ) { test_unit_skipped( tu ); }
0074     virtual void    test_unit_skipped( test_unit const& ) {} ///< backward compatibility
0075 
0076     //! Called when the test timed out
0077     //!
0078     //! This function is called to signal that a test unit (case or suite) timed out.
0079     //! A valid test unit is available through boost::unit_test::framework::current_test_unit
0080     virtual void    test_unit_timed_out( test_unit const& ) {}
0081 
0082     //! Called when a test unit indicates a fatal error.
0083     //!
0084     //! A fatal error happens when
0085     //! - a strong assertion (with @c REQUIRE) fails, which indicates that the test case cannot continue
0086     //! - an unexpected exception is caught by the Boost.Test framework
0087     virtual void    test_unit_aborted( test_unit const& ) {}
0088 
0089     virtual void    assertion_result( unit_test::assertion_result /* ar */ )
0090     {
0091     }
0092 
0093     //! Called when an exception is intercepted
0094     //!
0095     //! In case an exception is intercepted, this call happens before the call
0096     //! to @ref test_unit_aborted in order to log
0097     //! additional data about the exception.
0098     virtual void    exception_caught( execution_exception const& ) {}
0099 
0100     //! The priority indicates the order at which this observer is initialized
0101     //! and tore down in the UTF framework. The order is lowest to highest priority.
0102     virtual int     priority() { return 0; }
0103 
0104 protected:
0105 
0106     BOOST_TEST_PROTECTED_VIRTUAL ~test_observer() {}
0107 };
0108 
0109 } // namespace unit_test
0110 } // namespace boost
0111 
0112 #include <boost/test/detail/enable_warnings.hpp>
0113 
0114 #endif // BOOST_TEST_TEST_OBSERVER_HPP_021005GER
0115