xml_report_formatter.ipp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision$
  10. //
  11. // Description : OF_XML report formatter
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER
  14. #define BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER
  15. // Boost.Test
  16. #include <boost/test/results_collector.hpp>
  17. #include <boost/test/output/xml_report_formatter.hpp>
  18. #include <boost/test/tree/test_unit.hpp>
  19. #include <boost/test/utils/xml_printer.hpp>
  20. #include <boost/test/utils/basic_cstring/io.hpp>
  21. #include <boost/test/detail/suppress_warnings.hpp>
  22. //____________________________________________________________________________//
  23. namespace boost {
  24. namespace unit_test {
  25. namespace output {
  26. void
  27. xml_report_formatter::results_report_start( std::ostream& ostr )
  28. {
  29. ostr << "<TestResult>";
  30. }
  31. //____________________________________________________________________________//
  32. void
  33. xml_report_formatter::results_report_finish( std::ostream& ostr )
  34. {
  35. ostr << "</TestResult>";
  36. }
  37. //____________________________________________________________________________//
  38. void
  39. xml_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& ostr )
  40. {
  41. test_results const& tr = results_collector.results( tu.p_id );
  42. const_string descr;
  43. if( tr.passed() )
  44. descr = "passed";
  45. else if( tr.p_skipped )
  46. descr = "skipped";
  47. else if( tr.p_timed_out )
  48. descr = "timed-out";
  49. else if( tr.p_aborted )
  50. descr = "aborted";
  51. else
  52. descr = "failed";
  53. ostr << '<' << ( tu.p_type == TUT_CASE ? "TestCase" : "TestSuite" )
  54. << " name" << utils::attr_value() << tu.p_name.get()
  55. << " result" << utils::attr_value() << descr
  56. << " assertions_passed" << utils::attr_value() << tr.p_assertions_passed
  57. << " assertions_failed" << utils::attr_value() << tr.p_assertions_failed
  58. << " warnings_failed" << utils::attr_value() << tr.p_warnings_failed
  59. << " expected_failures" << utils::attr_value() << tr.p_expected_failures
  60. ;
  61. if( tu.p_type == TUT_SUITE ) {
  62. ostr << " test_cases_passed" << utils::attr_value() << tr.p_test_cases_passed
  63. << " test_cases_passed_with_warnings" << utils::attr_value() << tr.p_test_cases_warned
  64. << " test_cases_failed" << utils::attr_value() << tr.p_test_cases_failed
  65. << " test_cases_skipped" << utils::attr_value() << tr.p_test_cases_skipped
  66. << " test_cases_aborted" << utils::attr_value() << tr.p_test_cases_aborted
  67. << " test_cases_timed_out" << utils::attr_value() << tr.p_test_cases_timed_out
  68. << " test_suites_timed_out"<< utils::attr_value() << tr.p_test_suites_timed_out
  69. ;
  70. }
  71. ostr << '>';
  72. }
  73. //____________________________________________________________________________//
  74. void
  75. xml_report_formatter::test_unit_report_finish( test_unit const& tu, std::ostream& ostr )
  76. {
  77. ostr << "</" << ( tu.p_type == TUT_CASE ? "TestCase" : "TestSuite" ) << '>';
  78. }
  79. //____________________________________________________________________________//
  80. void
  81. xml_report_formatter::do_confirmation_report( test_unit const& tu, std::ostream& ostr )
  82. {
  83. test_unit_report_start( tu, ostr );
  84. test_unit_report_finish( tu, ostr );
  85. }
  86. //____________________________________________________________________________//
  87. } // namespace output
  88. } // namespace unit_test
  89. } // namespace boost
  90. #include <boost/test/detail/enable_warnings.hpp>
  91. #endif // BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER