Using BoostTest to run unit tests multiple times without quitting test runner

484 Views Asked by At

I want to use Boost Test to run unit tests multiple times without quitting the test runner. Here is the pseudo-code to demonstrate what I want to do:

void main() {
    for(int i = 0; i < 10; ++i) 
    {
            char *arguments[] ={ "MyApplication.exe", 
                                 "--detect_memory_leak=0" };
            boost::unit_test::unit_test_main( &init_function, 2, arguments);
     } 
}

The first time unit_test_main is called, all the boost tests run fine but in the second iteration, boost test throws an exception.

I looked at the internal code and found that framework is initialized everytime unit_test_main is called and if framework is already initialized, boost test doesn't like initializing framework again.

Please let me know if there is any way to run units test multiple times without quitting test runner.

1

There are 1 best solutions below

0
On

You'll need to implement your own test runner to replace stock unit_test_main. You can see what stock version is doing and add loop there.