|
1 // (C) Copyright Gennadiy Rozental 2005. |
|
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: xml_report_formatter.ipp,v $ |
|
9 // |
|
10 // Version : $Revision: 1.3 $ |
|
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 |
|
30 namespace boost { |
|
31 |
|
32 namespace unit_test { |
|
33 |
|
34 namespace output { |
|
35 |
|
36 void |
|
37 xml_report_formatter::results_report_start( std::ostream& ostr ) |
|
38 { |
|
39 ostr << "<TestResult>"; |
|
40 } |
|
41 |
|
42 //____________________________________________________________________________// |
|
43 |
|
44 void |
|
45 xml_report_formatter::results_report_finish( std::ostream& ostr ) |
|
46 { |
|
47 ostr << "</TestResult>"; |
|
48 } |
|
49 |
|
50 |
|
51 //____________________________________________________________________________// |
|
52 |
|
53 void |
|
54 xml_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 |
|
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 |
|
107 } // namespace unit_test |
|
108 |
|
109 } // namespace boost |
|
110 |
|
111 //____________________________________________________________________________// |
|
112 |
|
113 #include <boost/test/detail/enable_warnings.hpp> |
|
114 |
|
115 // *************************************************************************** |
|
116 // Revision History : |
|
117 // |
|
118 // $Log: xml_report_formatter.ipp,v $ |
|
119 // Revision 1.3 2005/12/14 05:39:43 rogeeff |
|
120 // *** empty log message *** |
|
121 // |
|
122 // Revision 1.2 2005/04/29 06:30:07 rogeeff |
|
123 // bug fix for incorect XML output |
|
124 // |
|
125 // Revision 1.1 2005/02/20 08:27:07 rogeeff |
|
126 // This a major update for Boost.Test framework. See release docs for complete list of fixes/updates |
|
127 // |
|
128 // *************************************************************************** |
|
129 |
|
130 #endif // BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER |