This section defines macros that can be used to register a test suite and its test cases.
Macro | Definition |
---|---|
CPPTEST_TEST_SUITE(TestSuiteName) | Begins the test case registration section in the test suite definition. |
CPPTEST_TEST_SUITE_END() | Ends the test case registration section in the test suite definition. |
CPPTEST_TEST(testCaseName) | The default test case registration. |
CPPTEST_TEST_EXCEPTION(testcasename, ExceptionType) | Used to specify that the given test case is expected to throw an exception. ExceptionType should be used to specify the type of exception. Since this will be used as the exception declaration in the catch clause, you can specify ... to indicate that the test case is expected to throw any exception. |
CPPTEST_TEST_ERROR(testcasename, ErrorCode) | Used to register a test case that is expected to cause a runtime error (e.g., division by zero, access violation, timeout, calling the exit() function etc.) The ErrorCode to be used in the macro can be taken from the C++test runtime problem report. For instance, if a test case "test_0" causes a timeout, C++test will report the following error: Timeout (5 seconds) reached. Test interrupted.
should be changed to: C++test will then expect that timeout is the expected result for the test case "test_0". |
CPPTEST_TEST_FAIL(testCaseName) | Used to specify that the given test case is expected to fail for some reason (e.g., an exception, timeout, failed assertion etc.). Since this macro does not allow you to specify the exact reason of the failure, it is better to use CPPTEST_TEST_ERROR() or CPPTEST_TEST_EXCEPTION() whenever possible. |
CPPTEST_TEST_DS(testCaseName, dsDefinition) | Used to register a test case that uses data from the given data source. The following macros can be used to define the data source:
|
CPPTEST_TEST_DISABLED(testcasename) | Registration of a disabled test case - it will not be executed. |
CPPTEST_TEST_EXCEPTION_DISABLED(testcasename, ExceptionType) | Registration of a disabled test case - it will not be executed. |
CPPTEST_TEST_ERROR_DISABLED(testcasename, ErrorCode) | Registration of a disabled test case - it will not be executed. |
CPPTEST_TEST_FAIL_DISABLED(testcasename) | Registration of a disabled test case - it will not be executed. |
CPPTEST_TEST_SUITE_REGISTRATION(TestSuiteName) | Registers test suite for execution. Has to be placed in the test suite source file. |
CPPTEST_CONTEXT(testedFile) | Using this macro in the test suite source code defines the given test suite tests’ specified source / header file. |
CPPTEST_TEST_SUITE_INCLUDED_TO(tested Source) | Using this macro in the test suite source code specifies that the given test suite will be appended to the end of the given source file when the test executable is built. |