Documentation

Link to Test Cases from Requirements

If you have Simulink® Test™ and Simulink Requirements™, you can link your requirements to test cases in the Test Manager. Linking to tests lets you see how requirements are confirmed with tests.

These links also help you to see your progress toward verifying the implementation of each requirement. Simulink Requirements can display verification status. Verification status helps you to see the requirements that are verified, the requirements that are missing tests, and whether tests associated with your requirements passed or failed.

In this tutorial, you link requirements to test cases associated with a controller model of an automobile cruise control system, managed in a Simulink project. After you run the tests, you include the results in the Requirements Editor.

  1. Open the project. At the MATLAB® command prompt, enter:

    slreqCCProjectStart
  2. Open the controller model. At the command prompt, enter:

    open_system('models/crs_controller')
  3. Open the Test Manager. In the model, select Analysis > Test Manager.

  4. In the Test Manager, from the tests folder, open the DriverSwRequest_Tests.mldatx test file.

  5. In the test browser, expand the test case hierarchy. The test file contains the test cases for several of the requirements in the crs_controller model. Most of these tests cases already link to requirements.

    You want to link the Increment button hold test to a requirement. Select that test case.

  6. In the model, select Analysis > Requirements > Requirements Editor. Expand the requirements set crs_req_func_spec.

  7. Right-click the requirement with the ID 1.3 (Long Switch recognition) and select Link from Selected Test.

    The link to the test case appears in the Links pane.

  8. Look at some of the other requirements, for example 1.8, 1.6, 1.9, and 1.4. Select each requirement and look at the Links pane. You can see the test case links under Verified by.

  9. Run all the tests that verify the linked requirements, including the linked test that you added. In the Test Manager, right-click the test file DriverSwRequest_Tests and select Run.

    The Results and Artifacts pane in the Test Manager shows that 7 tests passed and 1 test failed. Expand the results. The Cancel button test failed and the other tests passed.

  10. In the Requirements Editor, select Display > Verification Status. Resize the requirements browser window to see the Verified column.

    This view shows you the progress toward verification. Some requirements do not yet have tests. Some requirements are fully verified. The width of the verified display shows the proportion of subrequirements that have links to verification. The color of the display indicates the proportion of tests that have passed, failed, or not run.

    Here, the Cancel Switch Detection verification status shows that the test failed. Some requirements are partially verified because the subrequirements are not yet verified, such as requirement 1.8 in the figure. Hover over the verification status bar for details about the subrequirements.

Related Topics

Was this topic helpful?