概述
Through execution templates, you can wrap test cases at runtime to use your defined execution conditions for multiple scenarios. For example, instead of copying, pasting, and maintaining multiple test cases, you can create a single template that acts as a boilerplate to wrap the test cases at runtime.
依赖项
条件
- 当您运行或调试文件时,测试用例及其关联的执行模板将合并到一个临时文件中。系统会在运行时按名称比较两个文件中参数和变量的集合。如果执行模板与测试用例共享匹配的参数或变量名称,则合并后,系统将在“调用的工作流文件”中为其建立链接。如果测试用例没有任何与执行模板匹配的参数,则前一个文件中的参数将复制到后者。
- 移动或重命名执行模板会自动更新其相关测试用例。
- 发布包含执行模板的项目时,所有可发布的测试用例都将与执行模板合并。生成的文件即为项目的入口点。
- You can make use of reusable content by creating a library with execution templates.
- 您可以在工作流中调用多个占位符。
How it works
The execution template acts as a wrapper for test cases. In the Designer panel, you can see a placeholder activity within the execution template.

This activity is going to be replaced at runtime with an Invoke activity, adding the invoked test case to the execution template.

使用执行模板
To run a test case inside an execution template at runtime, follow these procedures:
创建执行模板
在将执行模板设置为测试用例之前,请创建该模板。
- 在 Studio 中打开工作流。
- In the Project panel, right-click the Templates folder to open the dropdown menu.
- 导航到“添加”>“执行模板”。
- Enter a name for your execution template and choose the location where it is going to be stored.

“新建”选项卡将在“设计器”面板中打开,并包含您的执行模板。您可以构建模板来满足您的测试需求。

- 执行模板创建完成后,单击“保存”。
向执行模板添加测试用例
To run or debug a test case with an execution template, you need to add it to an execution template (Set Execution Template). Alternatively, you can set an execution template for a newly created test case.
- Open or create your test case in Studio. If you do not have one yet, you can create a test case.
- 在“项目”面板中,右键单击一个测试用例以打开下拉菜单。
- 单击“设置执行模板”,然后从下拉列表中选择一个模板。
- 单击“确定”以确认。执行模板随即添加到测试用例中。系统将根据您关联的执行模板继续运行或调试此测试用例。

现在,您可以运行或调试测试用例,因为系统将使用执行模板执行该用例。
The placeholder activity needs to be included in the execution template. It will not work if it is in a different workflow that is invoked by the execution template.
额外操作
- 向测试用例添加测试数据
- 将测试用例发布到 Orchestrator
- 设置应用程序测试工作流分析器规则(请参阅执行模板中的占位符数量不正确)
从测试用例中删除执行模板
- 在 Studio 中打开工作流。
- In the Project panel, right-click a test case to open the dropdown menu.
Hover the mouse over a test case to show whether it is added to an execution template. - Click Set Execution Template and select <no execution template> from the dropdown list.
- 单击“确定”以确认。
2 个月前更新