Import Requirements from Test Specifications
You can use third-party applications like Microsoft® Word to author requirements and then import the requirements to Requirements Toolbox™. Importing requirements allows you to author and manage requirements in third-party tools and use Requirements Toolbox analyze and measure the traceability of those requirements.
In this step of the tutorial, you import requirements from a test specification authored in Microsoft Word, view the original requirements in the Word document, and link the requirements to MATLAB® tests.
View Test Specification
Open the MyAdd
project, which contains the test specification.
openProject("MyAdd");
Navigate to the documents
folder and open the test specification myAddTestSpecification.docx
.
The test specification describes how to test the myAdd
function. Some of the requirements for the test cases refine the functional requirements in myAddReqs
and add additional detail for how to test the function. Each requirement in the document has a bookmark.
Import Requirements from Microsoft Word
You can import requirements from Microsoft Word to Requirements Toolbox by opening the Requirements Editor and, in the File section, clicking Import. In the Importing Requirements dialog, you can choose the document type to import. Then, you can set the import settings to suit your needs.
In this example, the requirements are already imported from myAddTestSpecification.docx
with these settings selected:
The requirement set called myAddTestSpecification.slreqx
in the documents folder of the project contains the imported requirements.
View Imported Requirements
Open the imported requirement set.
slreq.open("myAddTestSpecification");
The imported requirements in the Requirements Editor retain the hierarchy from the Word document. The bookmarks from the Word document are the requirement IDs in the imported requirements.
Navigate from the requirement that has the summary Validity checks
back to the original requirement in Microsoft Word. In the Requirements Editor, select the requirement, and, in the right pane, under Properties, click Show in document. Microsoft Word opens the document and highlights the requirement.
Link Requirements to Tests
Open the test file tMyAdd.m
.
open tMyAdd
The tMyAdd
file is a test class that contains MATLAB tests for the myAdd
function. The tests verify the functional behavior described in myAddReqs
and the additional test requirements specified in myAddTestSpecification.docx
. The functions define the tests.
The requirements highlighting indicates that tests on lines 23, 26, 29, 39, 42 and 46 have links to requirements.
Open the Requirements Editor and click Show Links. The tMyAdd~m
link set contains links between the imported requirements and the tests in tMyAdd.m
.
The test defined on line 36 and the requirement with the summary Test for a positive input
do not have a link. Create the link between those items:
In
tMyAdd.m
, select line 36.In the Requirements Editor, click Show Requirements.
Select the requirement that has the summary
Test for a positive input
.Click Add Link > Link from Selection in MATLAB Editor.
Save the link set.
View Requirements as Document
View the requirements as a document. In the Requirements Editor, click Show Requirements > Document View. Maximize the viewing space by minimizing the right pane. In the right pane, click the Actions button and select Minimize.
The document view shows the verification links directly next to the requirements content.