1// (C) Copyright Gennadiy Rozental 2005-2008. 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: 49312 $ 11// 12// Description : 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/unit_test_suite_impl.hpp> 21#include <boost/test/output/xml_report_formatter.hpp> 22 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 30namespace boost { 31 32namespace unit_test { 33 34namespace output { 35 36void 37xml_report_formatter::results_report_start( std::ostream& ostr ) 38{ 39 ostr << "<TestResult>"; 40} 41 42//____________________________________________________________________________// 43 44void 45xml_report_formatter::results_report_finish( std::ostream& ostr ) 46{ 47 ostr << "</TestResult>"; 48} 49 50 51//____________________________________________________________________________// 52 53void 54xml_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& ostr ) 55{ 56 test_results const& tr = results_collector.results( tu.p_id ); 57 58 const_string descr; 59 60 if( tr.passed() ) 61 descr = "passed"; 62 else if( tr.p_skipped ) 63 descr = "skipped"; 64 else if( tr.p_aborted ) 65 descr = "aborted"; 66 else 67 descr = "failed"; 68 69 ostr << '<' << ( tu.p_type == tut_case ? "TestCase" : "TestSuite" ) 70 << " name" << attr_value() << tu.p_name.get() 71 << " result" << attr_value() << descr 72 << " assertions_passed" << attr_value() << tr.p_assertions_passed 73 << " assertions_failed" << attr_value() << tr.p_assertions_failed 74 << " expected_failures" << attr_value() << tr.p_expected_failures; 75 76 if( tu.p_type == tut_suite ) 77 ostr << " test_cases_passed" << attr_value() << tr.p_test_cases_passed 78 << " test_cases_failed" << attr_value() << tr.p_test_cases_failed 79 << " test_cases_skipped" << attr_value() << tr.p_test_cases_skipped 80 << " test_cases_aborted" << attr_value() << tr.p_test_cases_aborted; 81 82 83 ostr << '>'; 84} 85 86//____________________________________________________________________________// 87 88void 89xml_report_formatter::test_unit_report_finish( test_unit const& tu, std::ostream& ostr ) 90{ 91 ostr << "</" << ( tu.p_type == tut_case ? "TestCase" : "TestSuite" ) << '>'; 92} 93 94//____________________________________________________________________________// 95 96void 97xml_report_formatter::do_confirmation_report( test_unit const& tu, std::ostream& ostr ) 98{ 99 test_unit_report_start( tu, ostr ); 100 test_unit_report_finish( tu, ostr ); 101} 102 103//____________________________________________________________________________// 104 105} // namespace output 106 107} // namespace unit_test 108 109} // namespace boost 110 111//____________________________________________________________________________// 112 113#include <boost/test/detail/enable_warnings.hpp> 114 115#endif // BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER 116