In this example, you link a requirement to a MATLAB® script. The verification status in the Requirements Editor reflects the test results. This example performs the steps described in Linking to a Test Script. This example uses a requirements set file named counter_req.slreqx
, a MATLAB script called runmytests.m
that runs a test for the Counter
class in Counter.m
. The test script contains custom methods that write results a TAP format to a file named results.tap
.
Register the Custom Document Interface
Before creating the links, you need to register the custom document interface. Open the requirements file counter_req.slreqx
in the Requirements Editor:
Register the custom document interface that is specific to the external test file.
The custom logic in the GetResultFcn
function locates the test file that corresponds to the test case and fetches the results from that test file.
If the register command returns a warning, you must unregister the file and run the command again. To unregister the file, enter rmi unregister custom_mymscripttap
.
Create the Link
Make the struct containing properties of the external test. To create the link, at the command prompt, enter:
The requirement related to the link has its SID set to 2. To find the requirement related to the link, enter:
To create the link, enter:
This command creates the link between the test case counterStartsAtZero
and the requirement with the SID of 2. In the Requirements Editor, the link appears in the Details pane, under Links.
To avoid stale results, make sure that the timestamp of result file is latest than the timestamp of link creation. Open the result file, make a dummy change in the file and save it again to get the latest timestamp.
View the Verification Status
To view the verification status, you need to first update the verification status for the requirement set. At the MATLAB command prompt, type:
To see the verification status column in the Requirements Editor, ensure that Columns > Verification Status is selected. After the update, fetch the verification status for the requirement:
The Requirements Editor shows the verification status for entire requirements set that are passed or failed.
The verification status for the requirements for the counterStartsAtZero
is fully verified. Open the Requirements Editor to see the verification status:
The verification status shows that out of three tests, one test passed. Click Refresh to see the verification status for the requirements in the Requirements Editor.
Unregister the custom document interface.