Main Content

从测试设定导入需求

您可以使用第三方应用程序(例如 Microsoft® Word)来编写需求,然后将需求导入到 Requirements Toolbox™ 中。导入需求后,您便可以在第三方工具中编写和管理需求,并使用 Requirements Toolbox 分析和测量这些需求的可追溯性。

在本教程的这一步,您将从用 Microsoft Word 编写的测试设定中导入需求,查看 Word 文档中的原始需求,然后将这些需求链接到 MATLAB® 测试。

查看测试设定

打开 MyAdd 工程,其中包含测试设定。

openProject("MyAdd");

导航到 documents 文件夹并打开测试设定 myAddTestSpecification.docx

Screenshot of the test requirements in myAddTestSpecification.docx.

该测试设定描述了如何测试 myAdd 函数。测试用例的一些需求细化了 myAddReqs 中的功能需求,并添加了有关如何测试该函数的其他详细信息。文档中的每个需求都有一个书签。

从 Microsoft Word 导入需求

您可以通过打开需求编辑器,并在文件部分点击导入,将需求从 Microsoft Word 导入到 Requirements Toolbox。在“导入需求”对话框中,您可以选择要导入的文档类型。然后,您可以根据需要设置导入设置。

在此示例中,已从 myAddTestSpecification.docx 导入了需求并选择了以下设置:

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.

工程的 documents 文件夹中名为 myAddTestSpecification.slreqx 的需求集包含导入的需求。

查看导入的需求

打开导入的需求集。

slreq.open("myAddTestSpecification");

需求编辑器中导入的需求将保留 Word 文档中的层次结构。Word 文档中的书签是导入的需求中的需求 ID。

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.

从具有摘要 Validity checks 的需求导航回 Microsoft Word 中的原始需求。在需求编辑器中,选择需求,然后在右窗格中的属性下,点击在文档中显示。Microsoft Word 会打开文档并突出显示需求。

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

将需求链接到测试

打开测试文件 tMyAdd.m

open tMyAdd

tMyAdd 文件是一个测试类,其中包含适用于 myAdd 函数的 MATLAB 测试。这些测试用于验证 myAddReqs 中描述的功能行为以及 myAddTestSpecification.docx 中指定的其他测试需求。这些函数定义了测试。

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

需求突出显示表明第 23、26、29、39、42 和 46 行中的测试有指向需求的链接。

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.

打开需求编辑器,然后点击显示链接tMyAdd~m 链接集包含导入的需求和 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.

第 36 行定义的测试与具有摘要 Test for a positive input 的需求之间没有链接。请在这些项之间创建链接:

  1. tMyAdd.m 中,选择第 36 行。

  2. 在需求编辑器中,点击显示需求

  3. 选择具有摘要 Test for a positive input 的需求。

  4. 点击添加链接 > 从 MATLAB 编辑器中所选内容链接

保存链接集。

以文档形式查看需求

将需求视为文档。在需求编辑器中,点击显示需求 > 文档 视图。通过最小化右侧窗格来最大化查看空间。在右侧窗格中,点击“操作”按钮 并选择最小化

文档视图直接在需求内容旁边显示验证链接。

另请参阅

App

相关主题