- 概述
- UiPath CLI
- Azure DevOps 扩展程序
- Jenkins 插件
在 Test Manager 中测试包或运行测试集
借助 UiPath CLI,使用 Test Manager 测试 UiPath 包或运行测试集。
在 Test Manager 中测试包或运行测试集
先决条件
-
使用最新的 Test Manager 版本(对于交付 Automation Suite,请使用 Test Manager 2.2510 或更高版本;对于独立安装,请使用 Test Manager 25.10 或更高版本)。
-
如果您从 Orchestrator 引用现有测试集,请将测试集导入到 Test Manager。有关更多信息,请参阅Test Manager - 导入 Orchestrator 测试集。导入后获取测试集键。
-
在 Test Manager 中创建一个项目并获取项目密钥。从“Test Manager” >“所有项目” >“转到项目三点菜单” >“编辑” >“前缀” 中获取项目密钥。
-
使用自动化测试用例创建包或测试集。从 “Test Manager”>“测试集”选项卡 > “密钥”列中获取 “测试集密钥”。
-
获取客户端 ID 和客户端密码。有关如何获取客户端 ID 和客户端密码的更多信息,请参阅CI/CD 集成 - 执行 UiPath CLI 任务主题的注册外部应用程序部分。
-
运行 Windows/Linux/macOS 的 uipcli.dll 文件。
-
添加所需的 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) |
--testsetkey | The 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_path | json 输入文件的完整路径。有关文件结构的详细信息,请参阅输入参数 JSON 格式。 | 如果入口点工作流具有输入参数,则为必填项 |
--attachRobotLogs | 附加每个已执行测试用例的机器人日志和 JUnit 测试报告。 | 否 |
--repositoryUrl | 对项目进行版本控制的存储库 URL | 否 |
--repositoryCommit | 提交构建项目的存储库的版本 | 否 |
--repositoryBranch | 构建项目时使用的存储库分支 | 否 |
--repositoryType | VCS 系统存储库类型 | 否 |
--projectUrl | Automation 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, --accountName | Orchestrator CloudRPA 帐户名称。您必须将其与 OAuth2 刷新令牌和客户端 ID 配对 | 对于基于令牌的身份验证为必需 |
-A, --accountForApp | Orchestrator CloudRPA 帐户名称(组织名称)。您必须将其与外部应用程序的应用程序 ID、应用程序密码和应用程序作用域配对 | 否 |
-I, --applicationId | 外部应用程序 ID。您必须将其与“应用程序帐户”、“应用程序密码”和“应用程序作用域”配对 | 对于外部应用程序身份验证为必要项 |
-S, --applicationSecret | 外部应用程序密码。您必须将其与“应用程序帐户”、“应用程序 ID”和“应用程序作用域”配对 | 对于外部应用程序身份验证为必要项 |
--applicationScope | 应用程序作用域列表,以单个空格分隔。您必须将其与外部应用程序的应用程序账号、应用程序 ID 和应用程序密码配对 | 对于外部应用程序身份验证,可选。如果未另行指定,则使用默认作用域 |
-o, --organizationUnit | 要在其中执行测试集的 Orchestrator 文件夹 | 否 |
-l, --language | Orchestrator 用户界面中使用的语言 | 否 |
--traceLevel | 显示事件的追踪 | 否 |
--identityUrl | 身份服务器的 URL。当 Orchestrator 在UiPath Automation Suite或独立 Orchestrator (内部部署 MSI)上运行时为必需。Automation Cloud不需要 — CLI 从云 URL 解析身份服务器。 | 否 |
--ca-cert | Orchestrator/身份 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 支持两种输出格式:
| 格式 | 描述 | 用例 |
|---|---|---|
junit | JUnit XML 格式 | CI/CD 集成(Jenkins、Azure DevOps、GitHub Actions) |
uipath | UiPath 原生格式 | 包含 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"
主要差异
- 添加
--projectKey参数以启用 Test Manager - 使用
--testsetkey而不是-s进行测试集识别 - Test Manager 需要 OAuth 身份验证(应用程序凭据)
- 使用
--out指定输出格式并使用--result_path指定目标
最佳实践
Test Manager 设置
- 为不同的应用程序或团队创建专用的 Test Manager 项目
- 使用有意义的项目键和测试集键,以便于识别
- 按目的(回归、冒烟、集成等)组织测试集
参数管理
- 使用参数文件 (
-i) 进行特定于环境的配置 - 将敏感参数存储在 CI/CD 密码中,而不是参数文件中
- 在测试集说明中记录所需的参数
重试逻辑
- 将
--retryCount用于可能间歇性失败的不稳定测试 - 根据测试持续时间设置适当的
--timeout值 - 监控重试模式以识别和修复不稳定的测试
报告
- 对 CI/CD 管道集成使用
junit格式 - 在 Test Manager 中使用
uipath格式进行详细分析 - 启用
--attachRobotLogs以调试测试失败
CI/CD 集成
- 使用安全环境变量配置 Test Manager 身份验证
- 针对代码提交或拉取请求设置自动化测试执行
- 将测试报告存档为构建工件,以便追踪历史