This topic explains how you can focus your test suite on the test cases that are most important for your current goals and project phase. This is accomplished by removing test cases and/or disabling outcome checks that are not currently of concern to you.
Sections include:
If you do not want to use a test case at the current time, but think you might want to use it sometime in the future, you can disable it. Disabled test cases are not executed and their status is reported as "Test case execution disabled".
When a test case is disabled, its macros are changed as follows:
Macro for enabled test case | Macro for disabled test case |
---|---|
CPPTEST_TEST(testcasename) | CPPTEST_TEST_DISABLED(testcasename) |
CPPTEST_TEST_FAIL(testcasename) | CPPTEST_TEST_FAIL_DISABLED(testcasename) |
CPPTEST_TEST_EXCEPTION(testcasena me,ExcType) | CPPTEST_TEST_EXCEPTION_DISABLED(testca sename,ExcType) |
CPPTEST_TEST_ERROR(testcasename,E rrorCode) | CPPTEST_TEST_ERROR_DISABLED(testcasena me,ErrorCode) |
Test cases can be disabled (as well as later enabled) from the Test Case Explorer or from the project tree.
To disable a test case from the Test Case Explorer.
Disabled tests will be skipped during execution.
The Test Case Explorer’s filters can be used while enabling/disabling tests. If a test is “filtered out,” its status will not be modified.
If you later want to re-enable disabled test cases, right-click the related Test Case Explorer nodes, then choose Enable from the shortcut menu.
To disable a test case from the code editor:
Open the source code for the test you want to disable. You can do this by double-clicking the related project treenode.
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 Test suite tab for details).
CDT 4.x Note Test functions are not available in the project tree for Managed C/C++ projects created with CDT 4.x. To disable a test case, select the test case name in the code editor. |
You can later re-enable the test cases in the same manner (just choose Enable instead of Disable).
If you do not want to check a test case outcome right now, but think you might want to check it sometime in the future, you can add comments prevent C++test from checking it. If you later want to check that test case outcome, you can simply remove the comments:
To prevent the checking of a particular test case outcome:
Alternatively, you could manually comment out the source code for checking that outcome.
If you later want to re-enable checking of a disabled outcome, remove the comments.
Test cases can be deleted from the Test Case Explorer, project tree or from the Quality Tasks view. To permanently delete one or more test cases from the Test Case Explorer:
To permanently delete one or more test cases from the project tree:
In the project tree, select the test case(s) you want to delete.
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 Test suite tab for details).
CDT 4.x Note Test functions are not available in the project tree for Managed C/C++ projects created with CDT 4.x. To delete a test case, select the test case name in the code editor. |
Right-click the selection, then choose C++test> Remove Test Case(s) from the shortcut menu.
To permanently delete one or more test cases from the Quality Tasks view:
Test suites can be deleted from the Test Case Explorer, project tree or from the Quality Tasks view. To permanently delete one or more test suites from the Test Case Explorer:
To permanently delete an entire test suite from the project tree:
tests/autogenerated
directory within the tested project.Right-click the related test suite node, then choose Delete.