Documentation

Test Model Against Requirements and Report Results

  • Products Used
  • Simulink® Test™, Simulink Requirements™, Simulink Design Verifier™, Simulink Report Generator™, Microsoft® Word

Requirements Overview

Requirements are the basis for your system architecture, algorithm, and test plan. Traceability between requirements documents, model, code, and tests helps you document relationships, manage design changes, and interpret test results. Required model properties and test objectives enable targeted design analysis and test case generation for specific scenarios. You can evaluate your design and identify incomplete or missing requirements with ad-hoc testing, using simulated user interfaces for your model. Also, you can use rapid prototyping to validate requirements, and connect to physical or simulated environments to test your algorithm. Update the design, adding requirements and requirements links as necessary.

Test a Cruise Control Safety Requirement

This example shows a requirements-based testing workflow for a cruise control model. You start with a model that has traceability to an external requirements document. You add a test to evaluate two safety requirements, checking that the cruise control disengages when the system reaches certain conditions. You add traceability to this test, run the test, and report the results.

  1. Create a copy of the project in a working folder. Enter

    slVerificationCruiseStart
  2. Open the model and the test harness. On the command line, enter

    open_system simulinkCruiseAddReqExample
    sltest.harness.open('simulinkCruiseAddReqExample','SafetyTest_Harness1')
  3. Open the Test Sequence block.

    • The BrakeTest sequence tests that the system disengages when the brake pedal is pressed. It includes a verify statement

      verify(engaged == false,...
          'verify:brake',...
          'system must disengage when brake applied')

    • The LimitTest sequence tests that the system disengages when the speed exceeds a limit. It includes a verify statement

      verify(engaged == false,...
          'verify:limit',...
          'system must disengage when limit exceeded')

  4. Open the requirements document. In the Simulink Project window, expand the documents folder and open simulinkCruiseChartReqs.docx.

  5. Add links between the test steps and the requirements document.

    1. In the requirements document, highlight item 3.1, “Vehicle braking will transition system to disengaged (inactive) when engaged (active)”

    2. With item 3.1 highlighted, in the test sequence, right-click the BrakeTest step. Select Requirements traceability > Link to Selection in Word.

    3. In the requirements document, highlight item 3.4, “Transition to disengaged (inactive) when vehicle speed is outside the limits of 20 mph to 90 mph”

    4. With item 3.4 highlighted, in the test sequence, right-click the LimitTest step. Select Requirements traceability > Link to Selection in Word.

    5. Save the requirements document and the model.

  6. Create a test case in the Test Manager, and link the test case to the requirements section.

    1. Open the Test Manager. In the Simulink menu, select Analysis > Test Manager.

    2. In the Test Manager toolstrip, click New > Test File. Select the tests folder in the project, and enter a name for the test file. Click Save.

      A new baseline test is created.

    3. Under System Under Test, in the Model field, click the button to use the current model. The field displays the model name.

    4. Expand the Test Harness section. From the drop-down menu, select the test harness name.

    5. In the requirements document, highlight section 3.1.

    6. In the test case, expand the Requirements section. Click the arrow next to the Add button and select Link to Selection in Word.

    7. Use the same process to link the test case to section 3.4 in the requirements document.

  7. Highlight the test case. In the Test Manager toolstrip, click Run.

  8. When the test finishes, expand the Verify Statements results. The results show that both assessments pass, and the plot shows the detailed results of each statement.

  9. Create a report using a custom Microsoft Word template.

    1. In the Test Manager, right-click the test case name. Select Results: > Create Report.

    2. In the Create Test Result Report dialog box, set the options:

      • Title: SafetyTest

      • Results for: All Tests

      • File Format: DOCX

      • For the other options, keep the default selections.

    3. For the Template File, select the ReportTemplate.dotx file in the documents project folder.

    4. Enter a file name and select a location for the report.

    5. Click Create.

  10. Review the report.

    1. In the Test Case Requirements section, click the link to trace to the requirements document.

    2. The Verify Result section contains details of the two assessments in the test, and links to the simulation output.

Related Topics

Was this topic helpful?