Verify Requirements with MATLAB Tests
You can verify requirements by linking them to MATLAB® tests and running the tests by using the Requirements
Editor or the runTests
function. You can then view the requirements verification status in
the Requirements Editor.
If you have MATLAB Test™ and store your requirements and MATLAB tests in projects, you can verify the requirements when you run tests by using the MATLAB Test Manager (MATLAB Test). For more information, see Verify Requirements in Projects with MATLAB Tests (MATLAB Test).
Note
Test results from the Test Browser do not affect the verification status in the Requirements Editor.
Link Requirements and Tests
To link to a requirement from a MATLAB test:
Open a requirement set in the Requirements Editor. For more information, see Create, Open, and Delete Requirement Sets.
Open a MATLAB test file.
Select the function declaration line for the test.
In the Requirements Editor, select a requirement.
In the toolstrip, click Add Link > Link from Selection in MATLAB Editor.
Save the links by clicking Show Links, selecting the link set, and clicking Save.
By default, Requirements Toolbox™ sets the Type property to Verify
,
which enables the software to verify the requirement.
To save the links, in the Requirements Editor, click Show Links, select the link set, and click Save.
When you select a requirement, the Requirements Editor displays the linked tests in the right pane, under Links. For more information about requirement links, see Link Requirements to MATLAB Code and Create and Store Links.
Verify Requirements
To verify the requirements by running tests:
Open the MATLAB Test Manager and the Requirements Editor.
In the Requirements Editor, enable the verification status. In the Views section of the toolstrip, click the Columns button and ensure that Verification Status is selected.
Right-click a requirement set or an individual requirement and select Run Tests.
Note
Requirements Toolbox finds the tests that link to requirements in the requirement set or to the individual requirement and its child requirements, which can include MATLAB tests and Simulink® tests. For more information, see Review Requirements Verification Status.
In the Run Tests dialog, select the tests to run, then click Run Tests.
Tests with unresolved links are disabled. For more information on resolving links, see Load and Resolve Links.
You can also run the tests by passing an slreq.ReqSet
object as an input to the runTests
function.
Note
Use runTests
function to run the tests for MATLAB tests on requirements in the Requirements Editor using MATLAB
Online™.
View Verification Status
The requirements verification status reflects the results of linked MATLAB tests, Simulink Test test cases or other objects, and Simulink Design Verifier™ Proof Objective blocks and Model Verification blocks. For more information, see Review Requirements Verification Status.
To view the verification status , in the Requirements Editor, select Columns > Verification Status, then point to the bar in the Verified column. The tooltip displays details of the verification status. You can view the details for a requirement set, a parent requirement and its children, or a child requirement.
You can also get the verification status for a requirement set programmatically
by passing an slreq.ReqSet
object to the getVerificationStatus
function.
Generate Report with Verification Status
To generate a report that includes the requirements verification status for requirement sets, in the Requirements Editor, click Export > Generate Report. In the Report Generation Options dialog box, under Report content, select Verification Status. For more information, see Report Requirements Information.
You can generate the report programmatically by using the slreq.generateReport
function.