| 111 | Here's an alternative that IMHO is a little more elegant: |
| 112 | |
| 113 | {{{ |
| 114 | // |
| 115 | // run_tests.cc |
| 116 | // |
| 117 | |
| 118 | #define BOOST_AUTO_TEST_MAIN |
| 119 | |
| 120 | #include <iostream> |
| 121 | #include <fstream> |
| 122 | #include <cassert> |
| 123 | #include <boost/test/auto_unit_test.hpp> |
| 124 | #include <boost/test/results_reporter.hpp> |
| 125 | |
| 126 | struct ReportRedirector |
| 127 | { |
| 128 | std::ofstream out; |
| 129 | |
| 130 | ReportRedirector() : out("test_results.xml") |
| 131 | { |
| 132 | assert( out.is_open() ); |
| 133 | boost::unit_test::results_reporter::set_stream(out); |
| 134 | } |
| 135 | }; |
| 136 | |
| 137 | static ReportRedirector foo; |
| 138 | }}} |
| 139 | This has been tested for boost 1.35.0. |
| 140 | |