Test Model Against Requirements and Report Results - MATLAB & Simulink (original) (raw)

Main Content

Establishing traceability between requirements and test cases helps you interpret the test results and see the extent to which your model verifies your requirements. You can establish traceability by linking a requirement to the elements that verify it, such as the test cases in the Test Manager, verify statements in a Test Sequence block, or model verification blocks. When you run tests, a pass/fail summary appears in your requirements set.

This example demonstrates how to test the requirements of a cruise control system against a model. You start with a requirements set, a model, and a test case. You add traceability between the tests and the safety requirements, run the test, summarize the verification status, and report the results.

The requirements testing process. You start with system requirements, develop the architecture, then develop the model. Then you develop test cases and functional requirements, run the tests, and update the requirements and tests as necessary. You then report the results.

In this example, you test of two requirements in the requirement set:

Display the Requirements

  1. Open the example project.
    openExample("shared_vnv/CruiseControlVerificationProjectExample");
    pr = openProject("SimulinkVerificationCruise");
  2. Open the simulinkCruiseAddReqExample model.
    open_system("simulinkCruiseAddReqExample");
  3. Display the requirements. Click the icon in the lower-right corner of the model canvas, and select Requirements. TheRequirements pane opens.
  4. Display the verification and implementation status. Right-click the requirement set and select Verification Status andImplementation Status.
    Property Inspector and Requirements pane showing the implementation status for the model

Link the requirements to the test case.

  1. In MATLAB®, in the Project pane, in thetests folder, open the Simulink® Test™ fileslReqTests.mldatx. The test file opens in the Test Manager.
  2. In the model, click on requirement S 3.1.
  3. In the Test Manager, select the Safety Tests test case. In the right pane, in the Requirements section, click > . In the model, in the Property Inspector, the Verified by section indicates a link to the Safety Tests. In the Requirements pane, the yellow bars in the Verified column indicate that the linked tests have not been executed.
    Requirement dialog box showing linked tests to specific requirements
  4. Repeat the previous step to add a link for requirement S 3.4.

Run the Test

The test case uses a test harness named SafetyTest_Harness1. To open the test harness, click the icon in the lower-right corner of the model canvas and select SafetyTest_Harness1. In the test harness, open theTest Sequence block. The test sequence sets the input conditions and checks the model behavior:

  1. To run the test case, return to the Test Manager and clickRun.
  2. When the test finishes, review the results. In the Test Manager, in theResults and Artifacts pane, expand the test case and select Verify Statements. Then, in the Data Inspector tab, in the Inspect tab, select the verify statements. The plots provide the detailed results of each verify statement and show that both assessments pass.
    Test results for verify statements
  3. Return to the model and click the Refresh button in theRequirements pane to refresh the requirements. The green bar in the Verified column indicates that the test case successfully verified requirements S 3.1 and S 3.4.
    Verified status for requirements

Report the Results

Create a report using a custom Microsoft® Word template.

  1. In the Test Manager, in the Results and Artifacts pane, right-click the test case name. Select .
  2. In the Create Test Result Report dialog box, set these options:
    • TitleSafetyTest
    • Results forAll Tests
    • File FormatDOCX
  3. Enter a file name and select a location for the report.
  4. Set Template File to the fileReportTemplate.dotx file in thedocuments project folder.
  5. Click Create.
  6. Review the report.
    • The Test Case Requirements section specifies the associated requirements.
    • The Verify Result section contains details of the two assessments in the test and links to the simulation output.

See Also

Topics

External Websites