Main Content

Link Test Cases to Requirements Documents

Since requirements specify behavior in response to particular conditions, you can build test cases (test inputs, expected outputs, and assessments) from the model requirements. Test cases reproduce specific conditions using test inputs, and assess the actual model output against the expected outputs. As you develop the model, build test files that check system behavior and link them to corresponding requirements. By defining these test cases in test files, you can periodically check your model and archive results to demonstrate model stability.

Establish Requirements Traceability for Testing

If you have a金宝app®Test™and aRequirements Toolbox™license, you can link requirements to test harnesses, test sequences, and test cases. Before adding links, review金宝app支持需求文档类型.

Requirements Traceability for Test Harnesses

When you edit requirements links to the component under test, the links immediately synchronize between the test harness and the main model. Other changes to the component under test, such as adding a block, synchronize when you close the test harness. If you add a block to the component under test, close and reopen the harness to update the main model before adding a requirement link.

To view items with requirements links, on theAppstab, under Model Verification, Validation, and Test, clickRequirements Manager. In theRequirementstab, clickHighlight Links.

Requirements Traceability for Test Sequences

In test sequences, you can link to test steps. To create a link, first find the model item, test case, or location in the document you want to link to. Right-click the test step, selectRequirements, and add a link or open the link editor.

To highlight or remove the highlighting from test steps that have requirements links, toggle the requirements links highlighting buttonin the Test Sequence Editor toolstrip. Highlighting test steps also highlights the model block diagram.

Requirements Traceability for Test Cases

If you use many test cases with a single test harness, link to each specific test case to distinguish which blocks and test steps apply to it. To link test steps or test harness blocks to test cases,

  1. Open the test case in the Test Manager.

  2. In the left pane, in theTest Browsertab, select the test case.

  3. In Simulink in theAppstab, clickRequirements Manager.

  4. To link a test case to a:

    • Simulink block, right-click the block and selectRequirements>Link to Current Test Casefrom the context menu.

    • Test step, double-click the test sequence block in the test harness to open the Test Sequence Editor. Right-click the test step and selectRequirements>Link to Current Test Casefrom the context menu.

Requirements Traceability Example

This example demonstrates adding requirements links to a test harness and test sequence. The model is a component of an autopilot roll control system. This example requiresSimulink TestandRequirements Toolbox.

  1. Open the test file, the model, and the harness.

    openAutopilotTestFile.mldatxopen_systemRollAutopilotMdlRefsltest.harness.open('RollAutopilotMdlRef/Roll Reference',...'RollReference_Requirement1_3')
  2. In the test harness, on theAppstab, under Model Verification, Validation, and Test, clickRequirements Manager. In theRequirementstab, clickHighlight Links.

    The test harness highlights theTest Sequenceblock, component under test, andTest Assessmentblock.

  3. Add traceability to theDiscrete Derivativeblock.

    1. Right-click theDiscrete Derivativeblock and selectRequirements>Open Outgoing Links dialog.

    2. In theRequirementstab, clickNew.

    3. Enter the following to establish the link:

      • Description:DD link

      • Document type:Text file

      • Document:RollAutopilotRequirements.txt

      • Location:1.3辊保持参考

      要求输出链接s dialog box

    4. ClickOK. TheDiscrete Derivativeblock highlights.

  4. To trace to the requirements document, right-click the Discrete Derivative block, and selectRequirements>DD Link. The requirements document opens in the editor and highlights the linked text.

    Highlighted text that links to a requirement

  5. In the test harness, open theTest Sequenceblock. Add a requirements link that links theInitializeTeststep to the test case.

    1. In the Test Manager, in the left pane, in theTest Browsertab, selectRequirement 1.3 Test.

    2. In the test harness, double-click the test sequence block to open the Test Sequence Editor. Right-click theInitializeTeststep and selectRequirements>Link to Current Test Casefrom the context menu.

      When the requirements link is added, the Test Sequence Editor highlights the step.

      Highlighted test sequence step that is linked to a requirement

See Also

(Simulink Test)|