Line data Source code
1 : // (C) Copyright Gennadiy Rozental 2001. 2 : // Distributed under the Boost Software License, Version 1.0. 3 : // (See accompanying file LICENSE_1_0.txt or copy at 4 : // http://www.boost.org/LICENSE_1_0.txt) 5 : 6 : // See http://www.boost.org/libs/test for the library home page. 7 : // 8 : // File : $RCSfile$ 9 : // 10 : // Version : $Revision$ 11 : // 12 : // Description : OF_XML report formatter 13 : // *************************************************************************** 14 : 15 : #ifndef BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER 16 : #define BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER 17 : 18 : // Boost.Test 19 : #include <boost/test/results_collector.hpp> 20 : #include <boost/test/output/xml_report_formatter.hpp> 21 : 22 : #include <boost/test/tree/test_unit.hpp> 23 : #include <boost/test/utils/xml_printer.hpp> 24 : #include <boost/test/utils/basic_cstring/io.hpp> 25 : 26 : #include <boost/test/detail/suppress_warnings.hpp> 27 : 28 : //____________________________________________________________________________// 29 : 30 : namespace boost { 31 : namespace unit_test { 32 : namespace output { 33 : 34 : void 35 0 : xml_report_formatter::results_report_start( std::ostream& ostr ) 36 : { 37 0 : ostr << "<TestResult>"; 38 0 : } 39 : 40 : //____________________________________________________________________________// 41 : 42 : void 43 0 : xml_report_formatter::results_report_finish( std::ostream& ostr ) 44 : { 45 0 : ostr << "</TestResult>"; 46 0 : } 47 : 48 : 49 : //____________________________________________________________________________// 50 : 51 : void 52 0 : xml_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& ostr ) 53 : { 54 0 : test_results const& tr = results_collector.results( tu.p_id ); 55 : 56 0 : const_string descr; 57 : 58 0 : if( tr.passed() ) 59 0 : descr = "passed"; 60 0 : else if( tr.p_skipped ) 61 0 : descr = "skipped"; 62 0 : else if( tr.p_timed_out ) 63 0 : descr = "timed-out"; 64 0 : else if( tr.p_aborted ) 65 0 : descr = "aborted"; 66 : else 67 0 : descr = "failed"; 68 : 69 0 : ostr << '<' << ( tu.p_type == TUT_CASE ? "TestCase" : "TestSuite" ) 70 0 : << " name" << utils::attr_value() << tu.p_name.get() 71 0 : << " result" << utils::attr_value() << descr 72 0 : << " assertions_passed" << utils::attr_value() << tr.p_assertions_passed 73 0 : << " assertions_failed" << utils::attr_value() << tr.p_assertions_failed 74 0 : << " warnings_failed" << utils::attr_value() << tr.p_warnings_failed 75 0 : << " expected_failures" << utils::attr_value() << tr.p_expected_failures 76 : ; 77 : 78 0 : if( tu.p_type == TUT_SUITE ) { 79 0 : ostr << " test_cases_passed" << utils::attr_value() << tr.p_test_cases_passed 80 0 : << " test_cases_passed_with_warnings" << utils::attr_value() << tr.p_test_cases_warned 81 0 : << " test_cases_failed" << utils::attr_value() << tr.p_test_cases_failed 82 0 : << " test_cases_skipped" << utils::attr_value() << tr.p_test_cases_skipped 83 0 : << " test_cases_aborted" << utils::attr_value() << tr.p_test_cases_aborted 84 0 : << " test_cases_timed_out" << utils::attr_value() << tr.p_test_cases_timed_out 85 0 : << " test_suites_timed_out"<< utils::attr_value() << tr.p_test_suites_timed_out 86 : ; 87 0 : } 88 : 89 0 : ostr << '>'; 90 0 : } 91 : 92 : //____________________________________________________________________________// 93 : 94 : void 95 0 : xml_report_formatter::test_unit_report_finish( test_unit const& tu, std::ostream& ostr ) 96 : { 97 0 : ostr << "</" << ( tu.p_type == TUT_CASE ? "TestCase" : "TestSuite" ) << '>'; 98 0 : } 99 : 100 : //____________________________________________________________________________// 101 : 102 : void 103 0 : xml_report_formatter::do_confirmation_report( test_unit const& tu, std::ostream& ostr ) 104 : { 105 0 : test_unit_report_start( tu, ostr ); 106 0 : test_unit_report_finish( tu, ostr ); 107 0 : } 108 : 109 : //____________________________________________________________________________// 110 : 111 : } // namespace output 112 : } // namespace unit_test 113 : } // namespace boost 114 : 115 : #include <boost/test/detail/enable_warnings.hpp> 116 : 117 : #endif // BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER