Documentation

Link Tests to Requirements

Since requirements specify behavior in response to particular conditions, you can develop test inputs, expected outputs, and assessments from the model requirements.

Requirements Traceability Considerations

Consider the following limitations working with requirements links in test harnesses:

  • Some blocks and subsystems are recreated during test harness rebuild operations. Requirements linking is not supported for these blocks and subsystems in a test harness:

    • Conversion subsystems between the component under test and the sources or sinks

    • Test Sequence blocks that schedule function calls

    • Blocks that drive control input signals to the component under test

    • Blocks that drive Goto or From blocks that pass component under test signals

    • Data Store Read and Data Store Write blocks

  • If you use external requirements storage, performing the following operations requires reestablishing requirements links to model objects inside test harnesses:

    • Cut/paste or copy/paste a subsystem with a test harness

    • Clone a test harness

    • Move a test harness from a linked block to the library block

Establish Requirements Traceability for Testing

If you have a Simulink® Test™ and a Simulink Requirements™ license, you can link requirements to test harnesses, test sequences, and test cases. Before adding links, review Supported Requirements Document Types (Simulink Requirements).

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, select Analysis > Requirements Traceability > Highlight Model.

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, select Requirements Traceability, and add a link or open the link editor.

To highlight or unhighlight test steps that have requirements links, toggle the requirements links highlighting button in 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. Highlight the test case in the test browser.

  3. Right-click the block or test step, and select Requirements Traceability > Link to Current Test Case.

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 requires Simulink Test and Simulink Requirements.

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

    open AutopilotTestFile.mldatx,
    open_system RollAutopilotMdlRef,
    sltest.harness.open('RollAutopilotMdlRef/Roll Reference',...
    'RollReference_Requirement1_3')
  2. In the test harness, select Analysis > Requirements Traceability > Highlight Model.

    The test harness highlights the Test Sequence block, component under test, and Test Assessment block.

  3. Add traceability to the Discrete Derivative block.

    1. Right-click the Discrete Derivative block and select Requirements Traceability > Open Link Editor.

    2. In the Requirements tab, click New.

    3. Enter the following to establish the link:

      • Description: DD link

      • Document type: Text file

      • Document: RollAutopilotRequirements.txt

      • Location: 1.3 Roll Hold Reference

    4. Click OK. The Discrete Derivative block highlights.

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

  5. Open the Test Sequence block. Add a requirements link that links the InitializeTest step to the test case.

    1. In the Test Manager, highlight Requirement 1.3 Test in the test browser.

    2. Right-click the InitializeTest step in the Test Sequence Editor. Select Requirements Traceability > Link to Current Test Case.

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

Related Topics

Was this topic helpful?