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).
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.
Click Add Link > Link from Selection in MATLAB Editor.
Save the links by clicking Show Links, selecting the link set, and clicking Save.
Note
When you create a link between a requirement and a MATLAB test, Requirements Toolbox™ sets the link type to Verify
, which enables the
software to verify the requirement.
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 Create and Store Links.
Verify Requirements
To verify the requirements by running tests:
Open the Requirements Editor. For more information, see Open the Requirements Editor App.
In the Requirements Editor, 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.
You can also run the tests by passing an slreq.ReqSet
object as an input to the runTests
function.
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.