This topic explains best practices for addressing exception violations in common scenarios.
Scenario 1: Developer modified the source and needs to test the project to "No Exception" status
- Do one of the following:
- If you do not already have a project, create one.
- If you already have a project, update the project and related source files from source control.
- Generate and execute tests from the GUI.
- Review the reported exceptions and address them by fixing code, modifying the tests for proper setup, or verifying test cases that throw expected exceptions.
To verify test cases, use the following assertions in the generated test class file:
// Asserts that given expression throws an exception of specified type CPPTEST_ASSERT_THROW(expression, ExceptionType)
// Asserts that given expression throws an exception of specified type CPPTEST_ASSERT_THROW_MESSAGE(message, expression, ExceptionType)
Run the appropriate regression testing configuration to verify that tests pass.
- The exit criteria for this step is that no obsolete test cases are present, all functions have at least one test case, and all test cases pass (i.e., they do not throw unverified exceptions).
- Save the project.
- Check the project and related test assets (including test cases) into source control as described in Sharing Projects and Test Assets Through Source Control.
Scenario 2: Tests ran from the command line; developer needs to address reported exceptions
- Review the report and identify the project(s) that caused exceptions.
- Update the project and related source files from source control.
- Reproduce test case failures/exceptions using the local source and the configuration used by the scheduled command line regression tests.
- If access to the original project for scheduled regression tests is provided, the fixes can be performed using that set up.
- Address the reported exceptions by fixing code, modifying the tests for proper set up, or verifying test cases that throw expected exceptions.
To verify test cases, use the following assertions in the generated test class file:
// Asserts that given expression throws an exception of specified type CPPTEST_ASSERT_THROW(expression, ExceptionType)
// Asserts that given expression throws an exception of specified type CPPTEST_ASSERT_THROW_MESSAGE(message, expression, ExceptionType)
- Run the appropriate regression testing configuration to verify that tests pass.
- The exit criteria for this step is that no obsolete test cases are present, all functions have at least one test case, and all test cases pass (i.e., they do not throw unverified exceptions).
- Save the project.
- Check the project and related test assets (including test cases) into source control as described in Sharing Projects and Test Assets Through Source Control.