Renaming Test Suites
Test suite files should not be renamed. Doing so could prevent C++test from identifying and running the test suite.
Renaming Test Cases
To rename a test case:
- In the project tree, locate the test suite file that contains the test case(s) you want to rename.
- By default, automatically-generated test classes are saved in the
tests/autogenerated
directory within the tested project.
- To check or change where C++test is saving the test suite files, open the Test Configurations dialog, select the Test Configuration that was used for the test run that generated the tests, then review the value in the Generation> Test Suite tab’s Test suite output file and layout field (see Customizing Generation Options for details).
- By default, automatically-generated test classes are saved in the
- Double-click the project tree node that represents the test suite file. The file will open in an editor.
- Modify the test suite header as shown in the following examples:
- Test case registration section:
- Before:
CPPTEST_TEST(test_processData_123);
- After:
CPPTEST_TEST(test_processData_regression);
- Before:
- Test case declaration section:
- Before:
/* CPPTEST_TEST_CASE_DECLARATION test_processData_123 */
void test_processData_123();
- After:
/* CPPTEST_TEST_CASE_DECLARATION test_processData_regression */
void test_processData_regression();
- Before:
- Test case registration section:
- Modify the test suite definition as shown in the following examples:
- Before:
/* CPPTEST_TEST_CASE_BEGIN test_processData_123 */
void TestSuite_processData_1::test_processData_123(){
...
}
/* CPPTEST_TEST_CASE_END test_processData_123 */
- After:
/* CPPTEST_TEST_CASE_BEGIN test_processData_regression */
void TestSuite_processData_1::test_processData_regression(){
...
}
/* CPPTEST_TEST_CASE_END test_processData_regression */ - Save the modified file.
Updating Test Suites for a Renamed Source File
If the name of the tested file changes:
- In the project tree, locate the test suite file that contains the test case(s) you want to rename.
- By default, automatically-generated test classes are saved in the
tests/autogenerated
directory within the tested project. - To check or change where C++test is saving the test suite files, open the Test Configurations dialog, select the Test Configuration that was used for the test run that generated the tests, then review the value in the Generation> Test Suite tab’s Test suite output file and layout field (see Customizing Generation Options for details).
- By default, automatically-generated test classes are saved in the
- Double-click the project tree node that represents the test suite file. The file will open in an editor.
- Modify the
CPPTEST_CONTEXT
andCPPTEST_TEST_SUITE_INCLUDED_TO
macro values. - Save the modified file.