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

  1. 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.
  2. Generate and execute tests from the GUI.
  3. 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)
       

  4. 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).
  5. Save the project.
  6. 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

  1. Review the report and identify the project(s) that caused exceptions.
  2. Update the project and related source files from source control.
  3. 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.
  4. 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)
       

  5. 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).
  6. Save the project.
  7. Check the project and related test assets (including test cases) into source control as described in Sharing Projects and Test Assets Through Source Control.
  • No labels