Main Content

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.

Screenshot of the test requirements in 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:

Importing Requirements dialog with Document type set to Microsoft Word and these settings selected: Plain text, Use bookmarks to identify items and serve as custom IDs, Ignore outline numbers in section, Allow update from external source.

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.

The imported requirements from myAddTestSpecification.docx are shown and the hierarchy matches the hierarchy from the Word document, with the Validity checks requirement and Functional tests requirement as containers for the test 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.

The mouse points to the Show in document button in the right pane, under Properties. The tooltip says "Show the selected requirement in the external document."

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.

Lines 1-18 of the tMyAdd test file are shown, which includes the first test methods block with tags Functional and Integration.

The requirements highlighting indicates that tests on lines 23, 26, 29, 39, 42 and 46 have links to requirements.

The tMyAdd test file lines 20-51 are shown, which includes the test methods block with the Validity tag andf the test methods block with the Functional tag.

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 tMyAdd~m.slmx link set file is shown, with 7 verifies links between the imported test requirements and 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:

  1. In tMyAdd.m, select line 36.

  2. In the Requirements Editor, click Show Requirements.

  3. Select the requirement that has the summary Test for a positive input.

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

See Also

Apps

Classes

Related Topics