UiPath Documentation
cicd-integrations
2025.10
true
CI/CD 集成用户指南
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 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. 运行 Windows/Linux/macOS 的 uipcli.dll 文件。

  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 自动执行您的测试。

备注:

从 2018 年 10 月 25 日开始,CLI 通过 Test Manager 的异步 API 创建并执行暂态测试集,并轮询状态端点,直到测试集准备就绪。以前因 HTTP 超时而失败的大型暂态测试集现在可以成功完成。在创建过程中,CLI 会打印状态行,例如Test set creation is still in progress, retrying in 5 seconds... 。参数不更改 — 行为自动应用于每次test run --projectKey调用。

测试命令参数​
参数描述必填
Orchestrator URL (pos. 0)Orchestrator 实例的 URL是
Orchestrator Tenant (pos. 1)Test Manager 项目所在的租户。以Automation Cloud为目标时为必需。对于Automation Suite和独立 Orchestrator (内部部署 MSI)为可选,其中租户是 URL 的一部分。查看说明
-P, --project-path您要测试的测试包文件的路径否
--projectKey在“Test Manager”>“仪表板”选项卡 >“项目”>“所有项目”中显示的项目键。项目键是所有对象键的前缀。是(适用于 Test Manager)
--testsetkeyThe Test Set key displayed in Test Manager Test Manager > “测试集”选项卡 >“密钥”列中显示的测试集密钥。确保测试集包含最新版本的测试用例。如果项目未设置默认文件夹,请确保在测试集级别分配一个测试文件夹。否
-s, --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添加发行说明否
--author包作者。否
--nugetConfigFilePath还原期间使用的NuGet.Config文件的路径。从 2018 年 10 月 25 日起,文件将遵循端到端流程 — <clear /> 、 <packageSourceCredentials> 、 <packageSourceMapping>和<fallbackPackageFolders>都会生效。请参阅管理 NuGet 订阅源。在较旧的版本中,仅应用了<packageSources> URL。否
--disableBuiltInNugetFeeds禁用内置 NuGet 订阅源否
--excludeConfiguredSources不包括内置订阅源以及在运行 CLI 的主机上在用户和计算机级别配置的 NuGet 源。CLI 仅解析--nugetConfigFilePath中定义的订阅源中的包。请参阅管理 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身份服务器的 URL。当 Orchestrator 在UiPath Automation Suite或独立 Orchestrator (内部部署 MSI)上运行时为必需。Automation Cloud不需要 — CLI 从云 URL 解析身份服务器。否
--ca-certOrchestrator/身份 TLS 证书的受信任根 CA 文件(PEM、DER 或 PKCS#7)。重复或用逗号分隔。请参阅信任自定义证书。否
--pinnedpubkey固定叶公钥 ( sha256//<base64> )。请参阅信任自定义证书。否
提示:

对于私有证书颁发机构签名的 Orchestrator 实例(例如 UiPath Automation Suite),此命令也接受--ca-cert和--pinnedpubkey参数。有关场景和示例,请参阅信任自定义证书。

备注: 用于测试的默认应用程序作用域

使用外部应用程序身份验证而不指定--applicationScope参数时,CLI 会自动应用以下默认的 Test Manager 作用域:

TM.Projects TM.TestSets TM.TestExecutions

除了默认的 “或”作用域之外:

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" `
  -o "FolderName" `
  --out "junit" `
  --result_path "C:\TestResults"
  --author ExampleAuthor

# Linux/macOS
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" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./test-results"
  --author ExampleAuthor
# 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" `
  -o "FolderName" `
  --out "junit" `
  --result_path "C:\TestResults"
  --author ExampleAuthor

# Linux/macOS
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" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./test-results"
  --author ExampleAuthor

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

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

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" \
  -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" \
  -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" \
  -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" \
  -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" \
  -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" \
  -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" \
  -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" \
  -o "FolderName" \
  --out "junit" \
  --result_path "./results"

主要差异​

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

最佳实践​

Test Manager 设置​

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

参数管理​

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

重试逻辑​

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

报告​

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

CI/CD 集成​

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

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新