UiPath Documentation
uipath-cli
latest
false
UiPath CLI 用户指南
重要 :
请注意,此内容已使用机器翻译进行了本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。

uip tm 执行

“uip tm 执行”的语法和选项,可列出、筛选和重试测试执行,并检查已完成运行的测试用例日志。

uip tm executions检查和操作测试执行,即由uip tm testsets run生成的对象。这些动词列出测试集的执行,枚举已完成运行的测试用例日志,按 ID 重新运行现有执行,并且仅就地重试失败的用例。

启动执行的命令是uip tm testsets run ,该命令返回ExecutionId 。此页面上的每个动词均采用该 ID(或从上下文中派生)。

大纲

uip tm executions list --project-key <key> [--test-set-id <uuid>] [--filter <text>] [--limit <n>] [--offset <n>]
uip tm executions list-filtered --project-key <key> [--status <status>] [--execution-type <type>] [--execution-finished-interval <interval>] [--updated-by <userId>] [--search <text>] [--labels <labels...>] [--test-execution-ids <ids...>] [--sort-by <expr>] [--limit <n>] [--offset <n>]
uip tm executions testcaselogs list --execution-id <uuid> --project-key <key> [--only-failed] [--filter <text>] [--limit <n>] [--offset <n>]
uip tm executions run --project-key <key> --execution-id <uuid> --execution-type <type> [--test-case-log-ids <ids...>] [--async]
uip tm executions retry --execution-id <uuid> (--project-key <key> | --test-set-key <key>) [--execution-type <type>]
uip tm executions get-stats --execution-id <uuid> --project-key <key>
uip tm executions list --project-key <key> [--test-set-id <uuid>] [--filter <text>] [--limit <n>] [--offset <n>]
uip tm executions list-filtered --project-key <key> [--status <status>] [--execution-type <type>] [--execution-finished-interval <interval>] [--updated-by <userId>] [--search <text>] [--labels <labels...>] [--test-execution-ids <ids...>] [--sort-by <expr>] [--limit <n>] [--offset <n>]
uip tm executions testcaselogs list --execution-id <uuid> --project-key <key> [--only-failed] [--filter <text>] [--limit <n>] [--offset <n>]
uip tm executions run --project-key <key> --execution-id <uuid> --execution-type <type> [--test-case-log-ids <ids...>] [--async]
uip tm executions retry --execution-id <uuid> (--project-key <key> | --test-set-key <key>) [--execution-type <type>]
uip tm executions get-stats --execution-id <uuid> --project-key <key>

所有动词都遵循全局选项和标准退出代码。每个动词接受 --log-level <level>(默认值 Information)。

uip tm 执行列表

列出与测试集关联的执行。--test-set-id是可选的 — 省略它以列出项目中所有测试集的执行情况。

参数

无。

选项

标记描述
--project-key <key>必需。拥有的项目。
--test-set-id <uuid>测试集 UUID( Id中的testsets list字段,而不是TestSetKey )。
--filter <text>按名称搜索执行。
--limit <n>页面大小。默认为 50
--offset <n>要跳过的结果。默认为 0

示例

uip tm executions list \
  --project-key DEMO \
  --test-set-id a1b2c3d4-0000-0000-0000-000000000001 \
  --limit 2
uip tm executions list \
  --project-key DEMO \
  --test-set-id a1b2c3d4-0000-0000-0000-000000000001 \
  --limit 2

数据形状

{
  "Code": "ExecutionsList",
  "Data": [
    {
      "Id": "b2c3d4e5-0000-0000-0000-000000000001",
      "Name": "Nightly Run 2025-04-15",
      "Status": "Passed"
    },
    {
      "Id": "b2c3d4e5-0000-0000-0000-000000000002",
      "Name": "Nightly Run 2025-04-14",
      "Status": "Failed"
    }
  ]
}
{
  "Code": "ExecutionsList",
  "Data": [
    {
      "Id": "b2c3d4e5-0000-0000-0000-000000000001",
      "Name": "Nightly Run 2025-04-15",
      "Status": "Passed"
    },
    {
      "Id": "b2c3d4e5-0000-0000-0000-000000000002",
      "Name": "Nightly Run 2025-04-14",
      "Status": "Failed"
    }
  ]
}

已按列表筛选的 UIP TM 执行

使用高级服务器端筛选器列出执行。注意: --status--execution-type是单数单值标志。日期范围筛选是通过--execution-finished-interval完成的,而不是日期标志。

参数

无。

选项

标记描述
--project-key <key>必需。拥有的项目。
--status <status>按单个执行状态筛选。接受的值来自 SDK TestExecutionStatus 枚举 — 为当前集运行 --help
--execution-type <type>按单个执行类型筛选(automatedmanualmixednone)。
--execution-finished-interval <interval>按执行完成的期限筛选。接受的值来自 SDK TestExecutionFinishedInterval 枚举。
--updated-by <userId>按上次更新执行的用户 ID 筛选。
--search <text>对执行名称和元数据进行自由文本搜索。
--labels <labels...>要作为筛选依据的以空格分隔的标签名称。
--test-execution-ids <ids...>要包含的以空格分隔的执行 UUID。
--sort-by <expr>排序表达式(字段名称,可以选择添加 :asc:desc 后缀)。
--limit <n>页面大小。默认为 50
--offset <n>要跳过的结果。默认为 0

示例

uip tm executions list-filtered \
  --project-key DEMO \
  --status Failed \
  --execution-type automated \
  --limit 10
uip tm executions list-filtered \
  --project-key DEMO \
  --status Failed \
  --execution-type automated \
  --limit 10

数据形状

{
  "Code": "ExecutionsFilteredList",
  "Data": [
    {
      "Id": "b2c3d4e5-0000-0000-0000-000000000002",
      "Name": "Nightly Run 2025-04-14",
      "Status": "Failed",
      "ExecutionType": "automated"
    }
  ]
}
{
  "Code": "ExecutionsFilteredList",
  "Data": [
    {
      "Id": "b2c3d4e5-0000-0000-0000-000000000002",
      "Name": "Nightly Run 2025-04-14",
      "Status": "Failed",
      "ExecutionType": "automated"
    }
  ]
}

uip tm 执行测试用例日志列表

列出单次执行生成的测试用例日志。每个日志都是一个测试用例的运行,包含结果、状态和时间。

参数

无。

选项

标记描述
--execution-id <uuid>必需。要检查的执行。
--project-key <key>必需。拥有的项目。
--only-failed仅显示失败的日志。
--filter <text>按名称搜索日志。
--limit <n>页面大小。默认为 50
--offset <n>要跳过的结果。默认为 0

示例

uip tm executions testcaselogs list \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --project-key DEMO \
  --only-failed
uip tm executions testcaselogs list \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --project-key DEMO \
  --only-failed

数据形状

{
  "Code": "ExecutionTestCaseLogs",
  "Data": [
    {
      "Id": "c3d4e5f6-0000-0000-0000-000000000001",
      "TestCaseName": "Login flow",
      "Status": "Finished",
      "Result": "Failed"
    }
  ]
}
{
  "Code": "ExecutionTestCaseLogs",
  "Data": [
    {
      "Id": "c3d4e5f6-0000-0000-0000-000000000001",
      "TestCaseName": "Login flow",
      "Status": "Finished",
      "Result": "Failed"
    }
  ]
}

每个Id是一个测试用例日志 UUID。将其提供给uip tm testcaselogs list-assertions ,查看为何将测试用例日志标记为Failed

uip tm 执行运行

按 ID 重新运行现有执行。这与开始新的执行不同— 它会在同一执行记录中重播,针对所有测试用例或特定子集。

备注:

要开始全新的执行,请改用uip tm testsets run

参数

无。

选项

标记描述
--project-key <key>必需。拥有的项目。
--execution-id <uuid>必需。待重新运行的现有执行的 ID。
--execution-type <type>必需。要运行哪些测试用例(automatedmanualmixednone)。
--test-case-log-ids <ids...>用空格分隔的测试用例日志 UUID。如果提供,则仅重新运行这些特定日志。
--async排队后立即返回,无需等待确认。

示例

# re-run the entire execution
uip tm executions run \
  --project-key DEMO \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --execution-type automated

# re-run specific failed logs only
uip tm executions run \
  --project-key DEMO \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --execution-type automated \
  --test-case-log-ids c3d4e5f6-0000-0000-0000-000000000001 c3d4e5f6-0000-0000-0000-000000000002
# re-run the entire execution
uip tm executions run \
  --project-key DEMO \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --execution-type automated

# re-run specific failed logs only
uip tm executions run \
  --project-key DEMO \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --execution-type automated \
  --test-case-log-ids c3d4e5f6-0000-0000-0000-000000000001 c3d4e5f6-0000-0000-0000-000000000002

数据形状

{
  "Code": "ExecutionRun",
  "Data": {
    "ExecutionId": "a1b2c3d4-0000-0000-0000-000000000001",
    "Status": "Running",
    "StartTime": "2025-04-15T10:30:00Z"
  }
}
{
  "Code": "ExecutionRun",
  "Data": {
    "ExecutionId": "a1b2c3d4-0000-0000-0000-000000000001",
    "Status": "Running",
    "StartTime": "2025-04-15T10:30:00Z"
  }
}

uip tm 执行重试

仅就地重试已完成执行的失败测试用例。该命令将获取执行的统计信息,并拒绝继续,除非运行处于最终状态。如果有 0 个失败案例,则系统会退出0并显示一条消息。此重试会重用相同的执行 ID;此操作不会新建连接器。

参数

无。

选项

标记描述
--execution-id <uuid>必需。执行以重试。
--project-key <key>拥有的项目。这个或 --test-set-key 为必填项。
--test-set-key <key>测试集键(例如 DEMO:42);项目键从前缀派生。
--execution-type <type>重试的执行类型: automated (默认)manualmixednone

示例

uip tm executions retry \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --project-key DEMO
uip tm executions retry \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --project-key DEMO

数据形状 — 当重试失败时

{
  "Code": "ExecutionRetry",
  "Data": {
    "ExecutionId": "a1b2c3d4-0000-0000-0000-000000000001",
    "Status": "Running",
    "StartTime": "2025-04-15T10:30:00Z",
    "RetriedCount": 3
  }
}
{
  "Code": "ExecutionRetry",
  "Data": {
    "ExecutionId": "a1b2c3d4-0000-0000-0000-000000000001",
    "Status": "Running",
    "StartTime": "2025-04-15T10:30:00Z",
    "RetriedCount": 3
  }
}

数据形状 — 没有重试失败

{
  "Code": "ExecutionRetry",
  "Data": {
    "Message": "Execution 'a1b2c3d4-0000-0000-0000-000000000001' has no failed test cases to retry."
  }
}
{
  "Code": "ExecutionRetry",
  "Data": {
    "Message": "Execution 'a1b2c3d4-0000-0000-0000-000000000001' has no failed test cases to retry."
  }
}

uip tm 执行获取统计信息

按 ID 获取测试执行及其所有执行字段以及通过/失败/无聚合计数。当您需要带有统计信息的原始执行记录时,请使用此功能,例如,在调用 report get 之前检查执行是否已完成,或提取外部报告的时间和覆盖率数据。

参数

无。

选项

标记描述
--execution-id <uuid>必需。测试执行 UUID。从 uip tm testsets runuip tm testcases run 获取。
--project-key <key>必需。Test Manager 项目密钥(例如 DEMO)。

示例

uip tm executions get-stats \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --project-key DEMO
uip tm executions get-stats \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --project-key DEMO

数据形状

{
  "Code": "ExecutionGetStats",
  "Data": {
    "Id": "a1b2c3d4-0000-0000-0000-000000000001",
    "Name": "Nightly Run 2025-04-15",
    "Description": "Smoke + regression suite",
    "Status": "Finished",
    "ExecutionType": "automated",
    "Source": "Manual",
    "ProjectId": "00000000-0000-0000-0000-000000000abc",
    "TestSetId": "a1b2c3d4-0000-0000-0000-000000000010",
    "TestSetObjKey": "DEMO:10",
    "Passed": 8,
    "Failed": 2,
    "None": 0,
    "Duration": 3600000,
    "RunId": 12,
    "EnforceExecutionOrder": false,
    "EnableCoverage": false,
    "IsRunningAutomated": false,
    "HasTestsFromMultipleAutomationProjects": false,
    "RemoteControlAccess": "Disabled",
    "ExecutionStart": "2025-04-15T10:00:00Z",
    "ExecutionFinished": "2025-04-15T11:00:00Z",
    "ReportingDate": "2025-04-15T11:00:00Z",
    "FolderKey": "11111111-2222-3333-4444-555555555555",
    "Created": "2025-04-15T09:55:00Z",
    "CreatedBy": "11111111-2222-3333-4444-555555555555",
    "Updated": "2025-04-15T11:00:00Z",
    "UpdatedBy": "11111111-2222-3333-4444-555555555555",
    "AutopilotForRobotsSettings": { "Enabled": false },
    "OrderedExecutionSettings": { "Enabled": false },
    "VideoRecordingSettings": { "Enabled": false }
  }
}
{
  "Code": "ExecutionGetStats",
  "Data": {
    "Id": "a1b2c3d4-0000-0000-0000-000000000001",
    "Name": "Nightly Run 2025-04-15",
    "Description": "Smoke + regression suite",
    "Status": "Finished",
    "ExecutionType": "automated",
    "Source": "Manual",
    "ProjectId": "00000000-0000-0000-0000-000000000abc",
    "TestSetId": "a1b2c3d4-0000-0000-0000-000000000010",
    "TestSetObjKey": "DEMO:10",
    "Passed": 8,
    "Failed": 2,
    "None": 0,
    "Duration": 3600000,
    "RunId": 12,
    "EnforceExecutionOrder": false,
    "EnableCoverage": false,
    "IsRunningAutomated": false,
    "HasTestsFromMultipleAutomationProjects": false,
    "RemoteControlAccess": "Disabled",
    "ExecutionStart": "2025-04-15T10:00:00Z",
    "ExecutionFinished": "2025-04-15T11:00:00Z",
    "ReportingDate": "2025-04-15T11:00:00Z",
    "FolderKey": "11111111-2222-3333-4444-555555555555",
    "Created": "2025-04-15T09:55:00Z",
    "CreatedBy": "11111111-2222-3333-4444-555555555555",
    "Updated": "2025-04-15T11:00:00Z",
    "UpdatedBy": "11111111-2222-3333-4444-555555555555",
    "AutopilotForRobotsSettings": { "Enabled": false },
    "OrderedExecutionSettings": { "Enabled": false },
    "VideoRecordingSettings": { "Enabled": false }
  }
}

关键字段:

  • PassedFailedNone — 用于执行的聚合测试用例日志计数。
  • Duration — 执行总持续时间(以毫秒为单位)。
  • Status — 执行状态。当 Finished 时,以 Passed/Failed/None 计数为最终计数。
  • IsRunningAutomatedtrue,而系统仍在将自动化测试用例调度给机器人。
备注:

get-stats 返回带有计数的原始执行记录。对于包含每个测试用例失败消息的格式化摘要,请改用 uip tm report get

退出代码

标准 CI 模式是一个包含三步骤的管道:

  1. 启动uip tm testsets run返回ExecutionId并退出0
  2. 阻止uip tm wait会轮询,直到执行达到最终状态。完成时退出0 ,超时时退出2 ,失败时退出1
  3. 结论uip tm report get读取Passed / Failed项计数。您的脚本构建明确失败。
id=$(uip tm testsets run \
  --test-set-key DEMO:10 \
  --execution-type automated \
  --output-filter .Data.ExecutionId)

if ! uip tm wait --execution-id "$id" --project-key DEMO --timeout 1800000; then
  code=$?
  [ "$code" -eq 2 ] && { echo "timed out" >&2; exit 2; }
  echo "wait failed ($code)" >&2; exit "$code"
fi

failed=$(uip tm report get \
  --execution-id "$id" --project-key DEMO --output-filter .Data.Failed)
[ "$failed" -gt 0 ] && { echo "$failed test(s) failed" >&2; exit 1; }
echo "all passed"
id=$(uip tm testsets run \
  --test-set-key DEMO:10 \
  --execution-type automated \
  --output-filter .Data.ExecutionId)

if ! uip tm wait --execution-id "$id" --project-key DEMO --timeout 1800000; then
  code=$?
  [ "$code" -eq 2 ] && { echo "timed out" >&2; exit 2; }
  echo "wait failed ($code)" >&2; exit "$code"
fi

failed=$(uip tm report get \
  --execution-id "$id" --project-key DEMO --output-filter .Data.Failed)
[ "$failed" -gt 0 ] && { echo "$failed test(s) failed" >&2; exit 1; }
echo "all passed"

另请参阅

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新