Main Content

Verify Safety Requirements Linked to Test Steps Using Functional Requirements

This example shows you how to verify safety requirements linked to test sequences or assessment steps in the Requirements Editor. You first simulate the test cases associated with the functional requirements and then verify the safety requirements linked to verify statements in the test assessment block. This example uses a Cruise Control Model project.

Open the Project

This project contains:

  • Requirement sets for safety and functional requirements (crs_req_safety_spec.slreqx and crs_req_func_spec.slreqx,respectively)

  • A Simulink model (crs_controller)

  • A test harness for the model (crs_controller_Harness1)

  • A test assessment block

  • Test cases (crs_controller_tests)

  • Links from test assessment steps to requirements, and link set files stored in the src and tests folders

Follow these steps:

1. Open the CruiseRequirementsSafetyExample project. The project includes the model and supporting files.


2. Open the safety requirements for the crs_controller model."crs_req_safety_spec.slreqx");

3. Open the Simulink model and the harness for the model.

open_system("crs_controller");"crs_controller", "crs_controller_Harness1");


4. In the crs_controller_Harness1 harness model, double-click the Test Assessment block to open the test assessments. Each test step in a test assessment is linked to requirements from the crs_req_safety_spec.slreqx requirement set.

Observe Requirements Linked to Test Steps

1. To view the requirements associated with the test step, right-click the step and then click Requirements. Click Maximum Throttle Value to highlight the step in the test assessments and the requirement in the Requirements Editor.


2. In the Links section of Requirements Editor, observe the link coming from the test step. The link type of the requirements and links show as Verified by.


Run Tests for Functional Requirements

The crs_controller_tests file contains the test cases related to the functional requirements. Complete the following steps to test the functional requirements.

1. To open the Test Manager, in the Test Harness window, click Simulink Test Manager.

2. In the Test Manager, click Open Test File that will direct you to crs_controller_tests test file under Tests folder.


3. To run the tests, in the Test Browser tab, right-click crs_controller_tests and click Run. Simulink Test runs these tests and shows that all the tests have passed. You can also view the status of the verify statements associated with the test steps in the Results and Artifacts tab.


View Verification Status

You can now see if the tests ran in the Test Manager have been verified in the Requirements Editor.

1. In the View tab in the Requirements Editor, click Refresh. This updates the verification status of the requirements linked to the test steps.


2. Go to the Requirements Editor and click Refresh. Observe the verification status of all the linked requirements are passed. The unit test Unit_Tests_for_crs_controller ran for the functional requirements verified the safety requirements crs_req_safety_spec.slreqx in the Requirements Editor.


You can also run default simulation for the harness and verify safety requirements by viewing Simulation results in Simulink Data Inspector. The simulation, however will not run all the tests associated with the test file. Requirements Editor, on the other hand, fetches and assimilates verification data from Simulink Data Inspector runs. If you do not want certain runs to be considered in the final metric in the Requirements Editor, you can run and delete tests from the Simulink Data Inspector.

Related Topics