Main Content

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:

  1. Open a requirement set in the Requirements Editor. For more information, see Create, Open, and Delete Requirement Sets.

  2. Open a MATLAB test file.

  3. Select the function declaration line for the test.

    A function declaration line for a test is selected in the MATLAB editor.

  4. In the Requirements Editor, select a requirement.

  5. In the toolstrip, click Add Link > Link from Selection in MATLAB Editor.

    The Link from Selection in MATLAB Editor menu item is selected for a requirement.

  6. 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:

  1. Open the Requirements Editor. For more information, see Open the Requirements Editor App.

  2. 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.

  3. 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.

  4. In the Run Tests dialog, select the tests to run, then click Run Tests.

    The Run Tests dialog shows the linked tests for the requirement set, the test files, the test result for each test, and the index of the requirements that the tests verify.

    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 a requirement 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.

The mouse points to the Verified column for a requirement set that has four requirements. The tooltip indicates that four requirements link to tests that passed, one links to a test that failed, and three do not have links to tests.

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.

See Also

Apps

Functions

Classes

Related Examples

More About