Main Content

Link to Test Cases from Requirements

If you have金宝app®Test™andRequirements Toolbox™, 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.Requirements Toolboxcan 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 project. After you run the tests, you include the results in theRequirements 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 theAppstab, clickSimulink Test. In theTesttab, clickSimulink Test Manager.

  4. In theSimulink TestTest Manager, from thetestsfolder, open theDriverSwRequest_Tests.mldatx测试费尔e.

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

    Link theIncrement button holdtest to a requirement. Select that test case.

  6. Open theRequirements Editor. Navigate back to thecrs_controllerSimulink model. In theAppstab, underModel Verification, Validation, and Test, clickRequirements Editor.

  7. ClickShow Requirements. Display the requirements hierarchy forcrs_req_func_spec.

  8. Right-click the requirement with the ID1.3 (Long Switch recognition)and selectLink from Selected Test Case.

    The link to the test case appears in theDetailspane, underLinks.

  9. View verification information for other requirements1.4,1.6,1.8, and1.9by selecting each requirement. The links are displayed in theDetailspane underLinksunderVerified by.

  10. To run linked tests, in the Test Manager, select the top node in the test hierarchy in theTest Browserpane, then clickRun.

    TheResults and Artifactspane in the Test Manager shows that 7 tests passed and 1 test failed. Expand the results. TheCancel buttontest failed and the other tests passed.

  11. In theRequirements Editor中,选择Columns>Verification Status. Resize the requirements browser window to see theVerifiedcolumn.

    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, theCancel Switch Detectionverification status shows that the test failed. Some requirements are partially verified because the subrequirements are not yet verified, such as requirement1.8in the figure. Hover over the verification status bar for details about the subrequirements. Other requirements are unverified because they are not linked to a test case.

Related Topics