C++test can accommodate a number of strategies for programming test case-specific stub behavior. The most common strategy is to use dynamic stubs configuration (see Dynamic Stubs Configuration). In the rare instances that these approaches are insufficient, you can replace the stub body with your own custom logic implementation an create a stub that is driven by the test case.

The following functions can be used in the stub code to get information about the currently executed test case. This information is superseded by the dynamic stubs configuration functionality and should only be used for legacy stubs and for cases where dynamic stubs configuration functionality is insufficient.

MacroDefinition
const char* CppTest_GetCurrentTestCaseName()Returns the name of the currently executed test case.
const char* CppTest_GetCurrentTestSuiteName()Returns the name of the currently executed test suite.
bool CppTest_IsCurrentTestCase(const char* id)Allows you to query the currently executed test case. It will return true if the specified id equals the name of the currently executed test case. Otherwise, it will return false.
  • No labels