]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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( 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_aborted ) | |
63 | descr = "aborted"; | |
64 | else | |
65 | descr = "failed"; | |
66 | ||
67 | ostr << '<' << ( tu.p_type == TUT_CASE ? "TestCase" : "TestSuite" ) | |
68 | << " name" << utils::attr_value() << tu.p_name.get() | |
69 | << " result" << utils::attr_value() << descr | |
70 | << " assertions_passed" << utils::attr_value() << tr.p_assertions_passed | |
71 | << " assertions_failed" << utils::attr_value() << tr.p_assertions_failed | |
72 | << " warnings_failed" << utils::attr_value() << tr.p_warnings_failed | |
73 | << " expected_failures" << utils::attr_value() << tr.p_expected_failures; | |
74 | ||
75 | if( tu.p_type == TUT_SUITE ) { | |
76 | ostr << " test_cases_passed" << utils::attr_value() << tr.p_test_cases_passed | |
77 | << " test_cases_passed_with_warnings" << utils::attr_value() << tr.p_test_cases_warned | |
78 | << " test_cases_failed" << utils::attr_value() << tr.p_test_cases_failed | |
79 | << " test_cases_skipped" << utils::attr_value() << tr.p_test_cases_skipped | |
80 | << " test_cases_aborted" << utils::attr_value() << tr.p_test_cases_aborted; | |
81 | } | |
82 | ||
83 | ostr << '>'; | |
84 | } | |
85 | ||
86 | //____________________________________________________________________________// | |
87 | ||
88 | void | |
89 | xml_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 | ||
96 | void | |
97 | xml_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 | } // namespace unit_test | |
107 | } // namespace boost | |
108 | ||
109 | #include <boost/test/detail/enable_warnings.hpp> | |
110 | ||
111 | #endif // BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER |