Linking to a Result File
You can link a requirement to a test result file that is in Microsoft® Excel® format using the Outgoing Links Editor and the API. The verification status in the Requirements Editor reflects the test results. These illustrations follow the workflow for including external test results in the requirement verification status. For more information, see Include Results from External Sources in Verification Status.
Open Example Files
Open the Integrating Results from an External Result File example.
openExample(['slrequirements/' ... 'IntegratingResultsFromAnExternalResultFileExample'])
counter_req
requirement set in the Requirements
Editor. This requirement set has child requirements that have requirement IDs and
descriptions.
The external test results are contained in an Excel file called results.xlsx
. The verification status in
Requirements Toolbox™ updates based on the values of the cells in the Excel sheet. A unique ID in the Test column identifies each
result in the Status column. The Test and
Status labels are contained in a header row.
Create and Register a Custom Link Type
Before creating the links to the external result file, first create and register a custom link type.
Open the template file at
matlabroot/toolbox/slrequirements/linktype_examples/linktype_TEMPLATE.m
.
Follow these steps:
Create a new MATLAB file.
Copy the contents of
linktype_TEMPLATE
into the new file. Save the file aslinktype_myexternalresults.m
.In
linktype_myexternalresults.m
:Replace the function name
linktype_TEMPLATE
withlinktype_myexternalresults
.Set
linkType.Label
as'Excel Results'
.Set
linkType.Extensions
as{'.xlsx'}
.Uncomment the command for
GetResultFcn
in order to use it inlinktype_myexternalresults
and enter:For more information aboutlinktype.GetResultFcn = @GetResultFcn; ...... function result = GetResultFcn(link) testID = link.destination.id; if testID(1) == '@' testID(1) = []; end resultFile = link.destination.artifact; if ~isempty(resultFile) && isfile(resultFile) resultTable = readtable(resultFile); testRow = strcmp(resultTable.Test,testID); status = resultTable.Status(testRow); if status{1} == "passed" result.status = slreq.verification.Status.Pass; elseif status{1} == "failed" result.status = slreq.verification.Status.Fail; else result.status = slreq.verification.Status.Unknown; end else result.status = slreq.verification.Status.Unknown; end end
GetResultFcn
, see Links and Link Types.
Save
linktype_myexternalresults.m
.Register the link type. At the command line, enter:
rmi register linktype_myexternalresults
Note
If the command returns a warning, then you must unregister the link type and register it again. Unregister the link type by entering:
rmi unregister linktype_myexternalresults
Create a Requirement Link
You can create a link from a requirement to a test result for a test case from the external result file to confirm the requirement. You can create the link by using the Outgoing Links Editor, or by using the Requirements Toolbox API.
Create a Link by Using the Outgoing Links Editor
Create the link from a requirement to the external results file by using the Outgoing Links Editor:
Open the Requirements Editor and, in the
counter_req.slreqx
requirement set, right-click the child requirement1.3
and select Open Outgoing Links dialog.In the Outgoing Links Editor dialog box, in the Requirements tab, click New.
Enter these details to establish the link:
Description:
resultcounterSetsValue
Document type:
Excel Results
Document:
results.xlsx
Location:
counterSetsValue
Click OK. The link is highlighted in the Links section of the Requirements Editor.
Create a Link by Using the API
Create the link from a requirement to the external results file by using the API:
From the MATLAB® command prompt, enter:
externalSource.id = 'counterSetsValue'; externalSource.artifact = 'results.xlsx'; externalSource.domain = 'linktype_myexternalresults';
Open the requirement set and find the requirement related to the link:
reqSet = slreq.open('counter_req.slmx'); requirement = find(reqSet, 'Type', 'Requirement', 'SID', 4);
Create the link by entering:
This creates the link from the requirement withlink = slreq.createLink(requirement, externalSource);
SID
4
to the result for the test case in the external result file calledcounterSetsValue
. In the Requirements Editor, the link appears in the Links > Confirmed By section.
View the Verification Status
Update the verification information for the counterSetsValue
test
case based on the Excel status log by updating the verification status for the requirement
set.
You can update the verification status in the Requirements Editor by
clicking Refresh
. Ensure that Columns +
> Verification Status is selected to view the verification status for entire requirement
set.
The verification status shows that one of the three requirements is verified.
You can also update the verification status and fetch the current status by entering the following at the MATLAB command prompt:
updateVerificationStatus(reqSet) status = getVerificationStatus(reqSet)