2

I'm using Boost.Test for the unit testing of my class in C++. And I already created my test case using BOOST_AUTO_TEST_CASE. But I want to manually execute my test cases in my code. Like for example I have two testcases, and each test case I want to execute manually. Do I need to create a test runner for this? If yes, how can I create a basic test runner to execute my test cases individually?

Please advise.

Many thanks.

mockinterface
  • 14,452
  • 5
  • 28
  • 49
domlao
  • 15,663
  • 34
  • 95
  • 134

1 Answers1

0

You can use the fairly minimal harness already supplied with boost as follows:

// --- start main.cpp ---
#define BOOST_TEST_MAIN    
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE( testA )
{
    ...
}
// --- end ---

After you compile the file and link it with the unit_test_framework and test_exec_monitor boost libraries you can run the resulting executable, with the --run_test command line switch to select individual tests to run.

$ ./main.exe --run_test=testA
mockinterface
  • 14,452
  • 5
  • 28
  • 49