Helping getting started using Boost.Test

前端 未结 5 1217
后悔当初
后悔当初 2020-12-30 07:57

I am trying to start unit testing. I am looking at a few C++ frameworks and want to try Boost.Test. The documentation seems very thorough, and it\'s a bit overwhelming, espe

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-30 08:21

    You can start the tests from i.e. a menu command, but it's not that simple and sadly not well documented. Even more sad - its not possible to pass the path where the logfile is to be created. I had to add such a commandline option myself. Unfortunately i have not yet submitted it. My code looks like this:

    #ifdef DEBUG
    
    #undef main
    #define BOOST_TEST_MAIN
    #include 
    
    int DoUnitTests()
    
    {
        char *args[] = {"", "--log_level=all", "--auto_start_dbg=yes"};
    
        bool result = ::boost::unit_test::unit_test_main(&init_unit_test_suite, sizeof(args) / sizeof(char*), args);
    
        MessageDlog("Unittests result: %s", result ? "ERRORS in Unittests" :  "Goooood!");
        return result;
    }
    
    #else
    int DoUnitTests()
    
    {
    }
    #endif
    

提交回复
热议问题