UiPath Documentation
cicd-integrations
2023.10
false
CI/CD 集成用户指南
  • 概述
    • 关于 CI/CD 管道
  • UiPath CLI
  • Azure DevOps 扩展程序
  • Jenkins 插件
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。

在 Test Manager 中测试包或运行测试集

借助 UiPath CLI,使用 Test Manager 测试 UiPath 包或运行测试集。

在 Test Manager 中测试包或运行测试集​

先决条件​

  1. 使用最新的 Test Manager 版本(对于交付 Automation Suite,请使用 Test Manager 2.2510 或更高版本;对于独立安装,请使用 Test Manager 25.10 或更高版本)。

  2. 如果您已在 Orchestrator 中运行测试集,请将测试集导入到 Test Manager。有关更多信息,请参阅Test Manager - 导入 Orchestrator 测试集。导入后获取测试集键。

  3. 在 Test Manager 中创建一个项目并获取项目密钥。从 “Test Manager”>“仪表板”选项卡 >“项目”>“所有项目”中获取项目键。

  4. 使用自动化测试用例创建包或测试集。从 “Test Manager”>“测试集”选项卡 > “密钥”列中获取 “测试集密钥”。

  5. 获取客户端 ID 和客户端密码。有关如何获取客户端 ID 和客户端密码的更多信息,请参阅CI/CD 集成 - 执行 UiPath CLI 任务主题的注册外部应用程序部分。

  6. 运行 CLI exe (适用于 Windows)或dll (适用于 Linux)文件。

  7. 添加所需的 Test Manager API 访问应用程序作用域。有关 Test Manager 作用域的更多信息,请参阅CI/CD 集成 - 执行 UiPath CLI 任务主题。

将 Test Manager 与 CLI 结合使用​

要使用 Test Manager 测试包,请执行以下步骤:使用 uipcli test 运行测试任务。您可以看到一个可用子任务列表。指定所需的参数,然后运行“运行”子任务。

要使用 Test Manager 代替 Orchestrator 测试,请在test run命令中指定--projectKey参数。CLI 将通过 Test Manager 自动路由测试。

测试命令参数​
参数描述必填
Orchestrator URL (pos. 0)Orchestrator 实例的 URL是
Orchestrator Tenant (pos. 1)包或测试集所在的租户对于 SaaS 部署为必需,对于 PaaS 部署为可选
-P, --project-path您要测试的测试包文件的路径否
--projectKey在“Test Manager”>“仪表板”选项卡 >“项目”>“所有项目”中显示的项目键。项目键是所有对象键的前缀。是(适用于 Test Manager)
--testsetkey“Test Manager”>“测试集”选项卡 >“密钥”列中显示的测试集密钥。确保测试集包含最新版本的测试用例。如果测试集不在默认文件夹中,请确保在其前面添加相关文件夹名称。例如,“AccountingTeam\TestSet”。否
-s, --testset要执行的测试集的显示名称。确保测试集包含最新版本的测试用例。如果测试集不在默认文件夹中,请确保在其前面添加相关文件夹名称。例如,使用 AccountingTeam\TestSet否
--out结果文件的类型(junit 或 uipath)否
-r, --result_path要存储结果的文件的目标路径否
-e, --environment要部署包的环境。您必须将其与 project path对于传统文件夹为必要项
-w, --timeout等待测试集执行的时间(以秒为单位)。默认值为7200 秒。否
-i, --input_pathjson 输入文件的完整路径。有关文件结构的详细信息,请参阅输入参数 JSON 格式。如果入口点工作流具有输入参数,则为必填项
--attachRobotLogs为每个已执行的测试用例附加机器人日志和 JUnit 测试报告否
--repositoryUrl对项目进行版本控制的存储库 URL否
--repositoryCommit提交构建项目的存储库的版本否
--repositoryBranch构建项目时使用的存储库分支否
--repositoryTypeVCS 系统存储库类型否
--projectUrlAutomation Hub 概念 URL否
--releaseNotes添加发行说明否
--disableBuiltInNugetFeeds禁用内置 NuGet 订阅源否
--retryCount失败的测试用例的重试次数(默认情况下,未设置重试)否
-u, --username用于对 Orchestrator 进行身份验证的用户名。您必须将其与相应的密码配对对于基本身份验证需要
-p, --password用于对 Orchestrator 进行身份验证的密码。您必须将其与相应的用户名配对对于基本身份验证需要
-t, --token用于对 Orchestrator 进行身份验证的 OAuth2 刷新令牌。您必须将其与帐户名称和客户端 ID 配对对于基于令牌的身份验证为必需
-a, --accountNameOrchestrator CloudRPA 帐户名称。您必须将其与 OAuth2 刷新令牌和客户端 ID 配对对于基于令牌的身份验证为必需
-A, --accountForAppOrchestrator CloudRPA 帐户名称(组织名称)。您必须将其与外部应用程序的应用程序 ID、应用程序密码和应用程序作用域配对否
-I, --applicationId外部应用程序 ID。您必须将其与“应用程序帐户”、“应用程序密码”和“应用程序作用域”配对对于外部应用程序身份验证为必要项
-S, --applicationSecret外部应用程序密码。您必须将其与“应用程序帐户”、“应用程序 ID”和“应用程序作用域”配对对于外部应用程序身份验证为必要项
--applicationScope应用程序作用域列表,以单个空格分隔。您必须将其与外部应用程序的应用程序账号、应用程序 ID 和应用程序密码配对对于外部应用程序身份验证为必要项
-o, --organizationUnit要在其中执行测试集的 Orchestrator 文件夹否
-l, --languageOrchestrator 用户界面中使用的语言否
--traceLevel显示事件的追踪否
--identityURL您的 Identity Server 的 URL对于 PaaS 或 MSI 部署是必需的
备注: Test Manager 所需的应用程序作用域

使用 Test Manager 时,必须在--applicationScope参数中包含以下作用域:

TM.Projects TM.TestSets TM.TestExecutions

除 Orchestrator 作用域外:

OR.Assets OR.BackgroundTasks OR.Execution OR.Folders OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read

用法示例​

在 Test Manager 中执行现有测试集​
# Windows
uipcli test run "https://cloud.uipath.com/" "TenantName" `
  --projectKey "MyTestProject" `
  --testsetkey "MyTestSet" `
  -A "organizationName" `
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" `
  -S "********" `
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" `
  -o "FolderName" `
  --out "junit" `
  --result_path "C:\TestResults"

# Linux
uipcli test run "https://cloud.uipath.com/" "TenantName" \
  --projectKey "MyTestProject" \
  --testsetkey "MyTestSet" \
  -A "organizationName" \
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" \
  -S "********" \
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./test-results"
# Windows
uipcli test run "https://cloud.uipath.com/" "TenantName" `
  --projectKey "MyTestProject" `
  --testsetkey "MyTestSet" `
  -A "organizationName" `
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" `
  -S "********" `
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" `
  -o "FolderName" `
  --out "junit" `
  --result_path "C:\TestResults"

# Linux
uipcli test run "https://cloud.uipath.com/" "TenantName" \
  --projectKey "MyTestProject" \
  --testsetkey "MyTestSet" \
  -A "organizationName" \
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" \
  -S "********" \
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./test-results"

根据项目创建并执行暂态测试集​

暂态测试集是从项目路径即时创建的临时测试集。

uipcli test run "https://cloud.uipath.com/" "TenantName" \
  --projectKey "MyTestProject" \
  -P "./MyTestProject/project.json" \
  -e "TestEnvironment" \
  -A "organizationName" \
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" \
  -S "********" \
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" \
  -o "FolderName" \
  --out "uipath" \
  --result_path "./test-results"
uipcli test run "https://cloud.uipath.com/" "TenantName" \
  --projectKey "MyTestProject" \
  -P "./MyTestProject/project.json" \
  -e "TestEnvironment" \
  -A "organizationName" \
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" \
  -S "********" \
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" \
  -o "FolderName" \
  --out "uipath" \
  --result_path "./test-results"

使用参数覆盖执行测试​

uipcli test run "https://cloud.uipath.com/" "TenantName" \
  --projectKey "MyTestProject" \
  --testsetkey "MyTestSet" \
  -i "./test-parameters.json" \
  -A "organizationName" \
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" \
  -S "********" \
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./test-results"
uipcli test run "https://cloud.uipath.com/" "TenantName" \
  --projectKey "MyTestProject" \
  --testsetkey "MyTestSet" \
  -i "./test-parameters.json" \
  -A "organizationName" \
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" \
  -S "********" \
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./test-results"

使用机器人日志附件执行测试​

uipcli test run "https://cloud.uipath.com/" "TenantName" \
  --projectKey "MyTestProject" \
  --testsetkey "MyTestSet" \
  --attachRobotLogs true \
  -A "organizationName" \
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" \
  -S "********" \
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./test-results"
uipcli test run "https://cloud.uipath.com/" "TenantName" \
  --projectKey "MyTestProject" \
  --testsetkey "MyTestSet" \
  --attachRobotLogs true \
  -A "organizationName" \
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" \
  -S "********" \
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./test-results"

报告类型​

Test Manager 支持两种输出格式:

格式描述用例
junitJUnit XML 格式CI/CD 集成(Jenkins、Azure DevOps、GitHub Actions)
uipathUiPath 原生格式包含 Test Manager 特定数据的详细执行报告

从 Orchestrator 测试迁移​

之前(Orchestrator 测试)​

uipcli test run "https://cloud.uipath.com/" "TenantName" \
  -s "MyTestSet" \
  -u "username" \
  -p "password" \
  -o "FolderName" \
  -P "./project.json"
uipcli test run "https://cloud.uipath.com/" "TenantName" \
  -s "MyTestSet" \
  -u "username" \
  -p "password" \
  -o "FolderName" \
  -P "./project.json"

之后 (Test Manager)​

uipcli test run "https://cloud.uipath.com/" "TenantName" \
  --projectKey "MyTestProject" \
  --testsetkey "MyTestSet" \
  -A "organizationName" \
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" \
  -S "********" \
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./results"
uipcli test run "https://cloud.uipath.com/" "TenantName" \
  --projectKey "MyTestProject" \
  --testsetkey "MyTestSet" \
  -A "organizationName" \
  -I "becc663c-8f1e-409a-a75f-c00330d80bc8" \
  -S "********" \
  --applicationScope "OR.Folders OR.Execution TM.Projects TM.TestSets TM.TestExecutions OR.Assets OR.BackgroundTasks OR.Robots.Read OR.Machines.Read OR.Jobs OR.TestSets OR.TestSetExecutions OR.Monitoring OR.Settings.Read" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./results"

主要差异​

  1. 添加--projectKey参数以启用 Test Manager
  2. 使用--testsetkey而不是-s进行测试集识别
  3. Test Manager 需要 OAuth 身份验证(应用程序凭据)
  4. 使用--out指定输出格式并使用--result_path指定目标
  5. 将 Test Manager 作用域纳入--applicationScope中

最佳实践​

Test Manager 设置​

  • 为不同的应用程序或团队创建专用的 Test Manager 项目
  • 使用有意义的项目键和测试集键,以便于识别
  • 按目的(回归、冒烟、集成等)组织测试集

参数管理​

  • 使用参数文件 ( -i ) 进行特定于环境的配置
  • 将敏感参数存储在 CI/CD 密码中,而不是参数文件中
  • 在测试集说明中记录所需的参数

重试逻辑​

  • 将--retryCount用于可能间歇性失败的不稳定测试
  • 根据测试持续时间设置适当的--timeout值
  • 监控重试模式以识别和修复不稳定的测试

报告​

  • 对 CI/CD 管道集成使用junit格式
  • 在 Test Manager 中使用uipath格式进行详细分析
  • 启用--attachRobotLogs以调试测试失败

CI/CD 集成​

  • 使用安全环境变量配置 Test Manager 身份验证
  • 针对代码提交或拉取请求设置自动化测试执行
  • 将测试报告存档为构建工件,以便追踪历史

此页面有帮助吗?

连接

需要帮助? 支持(opens in new window)

想要了解详细内容? UiPath Academy(opens in new window)

有问题? UiPath 论坛(opens in new window)

保持更新