UiPath Documentation
studio
2023.4
false
Studio 用户指南
重要 :
新发布内容的本地化可能需要 1-2 周的时间才能完成。

Data Service

概述

您可以在 Automation Cloud 和 Automation Suite 中使用 Data Service 作为数据驱动测试的来源。数据从 Data Service 实体导入,将字段公开为工作流参数。所有导入的实体都存储在“项目”选项卡的“实体”下。为确保您拥有使用 Data Service 的必要许可证,请访问许可证分配和管理

只有使用 22.4 版或更高版本的 Testing.Activities 包,才能使用 Data Service 执行数据驱动的测试。

重要提示:

导入 Data Service 实体后,系统会在“参数”面板中生成一个参数。该参数的名称必须保持不变。如果更改参数的名称,您将无法再访问数据。

条件

  • 配置 Data Service 源时,将从实体中的第一个条目中提取数据。
  • To Run and Debug test cases with dynamic test data, use the Test Explorer. The data comes from the Data Service entity during runtime, and the Test Explorer populates the values at runtime.
  • 如果您关闭会话并再次打开项目,则需要再次运行包含数据变体的文件以加载测试数据。
  • 如果更新实体,则需要运行包含数据变体的文件,以加载更新的测试数据。
  • 数据变体为空的测试用例将标记为失败。
  • 当您执行包含来自 Data Service 的数据变体的测试用例时,系统会在 Orchestrator 中创建测试用例设置。

已知限制

  • For data-driven testing, the argument name generated by Data Service-driven test cases does not comply with the ST-NMG-002 workflow analyzer rule recommending the use of in_ and _out prefixes. Adapting the argument name to fit this rule may prevent data retrieval from the Data Service entity.

  • 如果您创建接受输入参数的数据驱动测试用例,将其发布到测试集中,并尝试直接从 Orchestrator 用户界面定义参数值,则输入参数值不会传递到测试变体。

    Workaround: To overcome this limitation, add the input argument directly to the Data Service entity.

应用实体筛选器

将测试数据添加到测试用例时,可以筛选实体以仅从 Data Service 检索特定字段。您可以使用内置的查询生成器配置筛选器。

  1. 单击“来源”,然后从下拉列表中选择“Data Service”。

    备注:

    If the option is not available, check the requirements.

  2. 选择一个实体或使用搜索功能进行查找。

  3. 单击“筛选器”图标以打开“查询生成器”。

  4. 使用第一个下拉列表,按条件(例如 CreateTime)进行筛选。

  5. (可选)单击“添加”,即可添加行和组,然后配置条件。

  6. (可选)您可以通过选择“AND”或“OR”来选择按所有或任何条件进行筛选。

  7. 输入筛选器的名称

  8. (可选)使用范围配置特定的行间隔。如果实体中有数百个字段,这将非常有用。

  9. Click OK to confirm.

    从实体中提取数据,并将其作为参数类型添加到测试用例中。仅提取实体中的第一个条目。您可以通过参数访问数据。

检索 Data Service 实体

在本教程中,您将学习如何检索 Data Service 实体,以执行数据驱动的测试。通过数据驱动的测试,您可以使用数据服务实体作为输入来高效地测试不同的数据场景。请按照以下步骤在测试用例中检索和利用 Data Service 实体。

  1. 创建测试自动化项目。

  2. “设计”功能区中,单击“管理实体”

    1. 取消选择所有实体,然后仅选择要在测试用例中检索的实体。

      在此示例中,我们仅选择了 Billings 实体。

    2. 单击“保存” ,将所选实体添加到您的项目中。

  3. 创建一个新的测试用例。

    1. “测试数据”选项卡中,选择Data Service 的“源”

    2. 选择要在测试用例中使用的实体。

      在此示例中,我们再次选择了 Billings 实体。

    3. 单击“创建”。

      With the test case, an argument is also created automatically in the Arguments panel, carrying the name of the entity. The type of the argument represents the namespace of the project and the name of the entity you selected as data source.

      重要提示:

      保留参数名称不变。否则,您将无法从实体中检索数据。

  4. 要从实体检索字段,请输入生成的参数,然后访问要检索的字段。 您可以使用以下格式检索实体中的字段和记录: <dataEntityName>.<fieldName>.toString

    在此示例中,我们添加了日志消息活动,并在“消息”字段中输入 billings.Data.toString

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新