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 | xml_report_formatter::results_report_start( std::ostream& ostr ) |
36 | { |
37 | ostr << "<TestResult>"; |
38 | } |
39 | |
40 | //____________________________________________________________________________// |
41 | |
42 | void |
43 | xml_report_formatter::results_report_finish( std::ostream& ostr ) |
44 | { |
45 | ostr << "</TestResult>"; |
46 | } |
47 | |
48 | |
49 | //____________________________________________________________________________// |
50 | |
51 | void |
52 | xml_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& ostr ) |
53 | { |
54 | test_results const& tr = results_collector.results( id: tu.p_id ); |
55 | |
56 | const_string descr; |
57 | |
58 | if( tr.passed() ) |
59 | descr = "passed"; |
60 | else if( tr.p_skipped ) |
61 | descr = "skipped"; |
62 | else if( tr.p_timed_out ) |
63 | descr = "timed-out"; |
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"<< utils::attr_value() << tu.p_name.get() |
71 | << " result"<< utils::attr_value() << descr |
72 | << " assertions_passed"<< utils::attr_value() << tr.p_assertions_passed |
73 | << " assertions_failed"<< utils::attr_value() << tr.p_assertions_failed |
74 | << " warnings_failed"<< utils::attr_value() << tr.p_warnings_failed |
75 | << " expected_failures"<< utils::attr_value() << tr.p_expected_failures |
76 | ; |
77 | |
78 | if( tu.p_type == TUT_SUITE ) { |
79 | ostr << " test_cases_passed"<< utils::attr_value() << tr.p_test_cases_passed |
80 | << " test_cases_passed_with_warnings"<< utils::attr_value() << tr.p_test_cases_warned |
81 | << " test_cases_failed"<< utils::attr_value() << tr.p_test_cases_failed |
82 | << " test_cases_skipped"<< utils::attr_value() << tr.p_test_cases_skipped |
83 | << " test_cases_aborted"<< utils::attr_value() << tr.p_test_cases_aborted |
84 | << " test_cases_timed_out"<< utils::attr_value() << tr.p_test_cases_timed_out |
85 | << " test_suites_timed_out"<< utils::attr_value() << tr.p_test_suites_timed_out |
86 | ; |
87 | } |
88 | |
89 | ostr << '>'; |
90 | } |
91 | |
92 | //____________________________________________________________________________// |
93 | |
94 | void |
95 | xml_report_formatter::test_unit_report_finish( test_unit const& tu, std::ostream& ostr ) |
96 | { |
97 | ostr << "</"<< ( tu.p_type == TUT_CASE ? "TestCase": "TestSuite") << '>'; |
98 | } |
99 | |
100 | //____________________________________________________________________________// |
101 | |
102 | void |
103 | xml_report_formatter::do_confirmation_report( test_unit const& tu, std::ostream& ostr ) |
104 | { |
105 | test_unit_report_start( tu, ostr ); |
106 | test_unit_report_finish( tu, ostr ); |
107 | } |
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 |
118 |