$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2006-06-09 14:36:34
<hfye-wila_at_[hidden]> wrote in message 
news:000501c68bea$0018c7f0$6501a8c0_at_Furst...
Sorry hit send by mistake first time.
> To output to files, I use set_stream.  I found it made things easier to 
> have
> my own version  of Boost.Test's "main" function, like this:
>
>    // based on: "main" in <boost\test\impl\unit_test_main.ipp>
>    int my_unit_test_entrypoint() {
>        using namespace ::boost::unit_test;
>        int ret = boost::exit_exception_failure;
>        try {
>            char * argv[] = { /*add cmdline options here*/ }; // see above
>            int argc = sizeof( argv ) / sizeof( char * );
>
>            framework::init( argc, argv );
>
>            std::ofstream logStream( "c:\\log.xml" );
>            unit_test_log.set_stream( logStream );
>
>            framework::run();
>
>            std::ofstream reportStream( "c:\\report.xml" );
>            results_reporter::set_stream( reportStream );
>
>            results_reporter::make_report();
>
>            if ( runtime_config::no_result_code() ) {
>                ret = boost::exit_success;
>            } else {
>                test_unit_id id = framework::master_test_suite().p_id;
>                ret = results_collector.results( id ).result_code();
>            }
>        }
>        catch( std::logic_error const & ex ) { /*add error reporting here*/
> }
>        catch( ... ) { /*add error reporting here*/ }
>        return ret;
>    }
You don't really need to rewrite main to implement redirection. There are 
several ways to do this. One of simplest id to use global fixture:
std::ofstream logStream;
std::ofstream reportStream;
struct output_setup {
    output_setup()
    {
        logStream.open( "c:\\log.xml" );
        unit_test_log.set_stream( logStream );
        reportStream.open( "c:\\report.xml" );
        results_reporter::set_stream( reportStream );
   }
};
BOOST_GLOBAL_FIXTURE( output_setup );
Gennadiy