Registering Test Suites

If you have created a test suite with test helper macros, you can register it to the test registry automatically using the REGISTER_TESTSUITE() macro.

To register a test suite automatically, implement the REGISTER_TESTSUITE() macro in the test suite .cpp file. You can use the Osp::Test::TestRegistry class to retrieve the list of test suites registered in the test registry.

The following code snippet illustrates how to register a test suite using a macro and how to retrieve the registered test suites.

// in TestBankAccount.cpp
REGISTER_TESTSUITE(TestBankAccount)

void RunTest()
{
   // Add the test suite to the test runner
   pTestRunner->AddTestSuites(*Osp::Test::TestRegistry::Instance()->GetTestSuitesN());

   // Run the test suite
}

Where to Go Next