UiPath Documentation
uipath-cli
latest
false
重要 :
このコンテンツは機械翻訳によって処理されています。 新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。

UiPath CLI ユーザー ガイド

方法: CLI からテストを実行する

このページでは、CI パイプラインの一部として CLI から UiPath Test Manager のテスト セットを実行する方法と、同様に重要なこととして、判定を正しく読み取る方法について説明します。uip tmツールがテスト実行を3つの動詞に分割するのには理由があります。そのうちの 1 つだけを使用すると、テストが失敗した場合でも、ビルドに合格する可能性があります。

黄金律: 起動→待機→検証

テストが失敗したために、1 つの uip tm 動詞が 0 以外から出ることはありません。赤いテスト実行でパイプラインが失敗するようにするには、次の 3 つのコマンドが必要です。

  1. 起動uip tm testsets run.実行をキューに登録し、Orchestrator が要求を受け入れるとすぐに 0 を終了します。応答のStatus: "Running"は、最終的な結果ではなく、開始時の状態を反映しています。
  2. ブロックuip tm wait。実行が終了ステート (PassedFailedCancelled) に達するまでポーリングします。終了状態に達すると0終了します—「終了」はwaitの成功シグナルであるためです。--timeout2を終了します(認証エラースロットのドメイン固有の再利用により、テキストを解析せずにスクリプトが「時間がかかりすぎた」で分岐できます)。
  3. 確認uip tm report getData.Failed (および PassedSkippedPassRate) を読み取ります。終了 0 、成功/不合格に関係なく、概要を正常に取得するたびに、スクリプトは Data.Failed > 0 をゼロ以外の終了に変える役割を担います。

ショートカット パターンは存在しますが (たとえば、uip or jobs start --wait-for-completionは 1 つのジョブで待機 + 検証します)、テスト セットには存在しません。常に3つのステップを書きます。

実用最小限のスニペット

#!/usr/bin/env bash
set -euo pipefail

# 1. Launch
EXECUTION_ID=$(uip tm testsets run \
  --test-set-key DEMO:10 \
  --output-filter "Data.ExecutionId" \
  --output plain)

# 2. Block (default timeout: 30 min; adjust with --timeout)
if ! uip tm wait \
  --execution-id "$EXECUTION_ID" \
  --project-key DEMO \
  --timeout 1800; then
  code=$?
  if [ "$code" -eq 2 ]; then
    echo "test run did not finish within 30 minutes" >&2
    exit 2
  fi
  echo "wait failed (exit $code)" >&2
  exit "$code"
fi

# 3. Verify
FAILED=$(uip tm report get \
  --execution-id "$EXECUTION_ID" \
  --project-key DEMO \
  --output-filter "Data.Failed" \
  --output plain)

if [ "$FAILED" -gt 0 ]; then
  echo "$FAILED test case(s) failed" >&2
  exit 1
fi

echo "all tests passed"
#!/usr/bin/env bash
set -euo pipefail

# 1. Launch
EXECUTION_ID=$(uip tm testsets run \
  --test-set-key DEMO:10 \
  --output-filter "Data.ExecutionId" \
  --output plain)

# 2. Block (default timeout: 30 min; adjust with --timeout)
if ! uip tm wait \
  --execution-id "$EXECUTION_ID" \
  --project-key DEMO \
  --timeout 1800; then
  code=$?
  if [ "$code" -eq 2 ]; then
    echo "test run did not finish within 30 minutes" >&2
    exit 2
  fi
  echo "wait failed (exit $code)" >&2
  exit "$code"
fi

# 3. Verify
FAILED=$(uip tm report get \
  --execution-id "$EXECUTION_ID" \
  --project-key DEMO \
  --output-filter "Data.Failed" \
  --output plain)

if [ "$FAILED" -gt 0 ]; then
  echo "$FAILED test case(s) failed" >&2
  exit 1
fi

echo "all tests passed"

--output plain は、スカラー フィルター結果の裸の値を返します。これは、JSON を解析せずにフィールドをシェル変数にキャプチャする最も安全な方法です。「スクリプティング パターン — エンベロープから値を読み取る」を参照してください。

コマンドへの入力の選択

uip tm testsets run UUIDではなく、 テストセットキーが必要です。キーの形式は <ProjectKey>:<Number> です (例: DEMO:10)。検索方法は 2 つあります。

# From the Test Manager UI — it is the "Key" column in the test set list.

# Or from the CLI:
uip tm testsets list --project-key DEMO --filter smoke \
  --output-filter "Data[*].{key:TestSetKey, name:Name}"
# From the Test Manager UI — it is the "Key" column in the test set list.

# Or from the CLI:
uip tm testsets list --project-key DEMO --filter smoke \
  --output-filter "Data[*].{key:TestSetKey, name:Name}"

--project-keylistに必須です。 run は、テスト セット キーのプレフィックス (DEMO:10 → プロジェクト DEMO) からプロジェクトを派生させます。

uip tm executions list --test-set-idに数値のUUIDが必要な場合、それは同じリスト出力のIdフィールドであり、TestSetKeyではありません

実行するケースを選択する

uip tm testsets run --execution-typeセット内のどのテスト ケースを実行するかを制御します。

  • automated (既定) — 自動化されたテスト ケースのみ。
  • manual — 手動テスト用のテスト ケースのみ
  • mixed — 両方です。
  • none — 型フィルターなし。

CIの場合、デフォルト(automated)のままにします—手動のケースでは、人間が合格/不合格をマークする必要があり、--timeoutまでInProgressに座ります。

パラメーターの上書きを渡す

テスト セットでパラメーター (ターゲット URL やアカウント ID など) が公開されている場合は、起動時に --input-pathで上書きします。

cat > ./params.json <<'EOF'
[
  {"name": "TargetUrl", "type": "String", "value": "https://staging.example.com"},
  {"name": "AccountId", "type": "String", "value": "acme-staging"}
]
EOF

uip tm testsets run --test-set-key DEMO:10 --input-path ./params.json
cat > ./params.json <<'EOF'
[
  {"name": "TargetUrl", "type": "String", "value": "https://staging.example.com"},
  {"name": "AccountId", "type": "String", "value": "acme-staging"}
]
EOF

uip tm testsets run --test-set-key DEMO:10 --input-path ./params.json

上書きは、 name (大文字と小文字を区別しません) によってテスト セットの現在のパラメーター定義と照合され、存在する場合は typeされます。サーバーがパラメーター定義を報告しない場合、入力はそのまま送信されます。

評決を詳しく読む

uip tm report getは要約リーダーです。デフォルトの出力ではスコアカードが表示されます。 --query (JQ スタイルのフィルター) を渡して、1 回の呼び出しでサブセットを抽出します。

# Pretty scorecard
uip tm report get --execution-id "$EXECUTION_ID" --project-key DEMO

# Script-friendly — JSON with just the counts
uip tm report get --execution-id "$EXECUTION_ID" --project-key DEMO \
  --query '{total: .TotalTests, passed: .Passed, failed: .Failed}'
# Pretty scorecard
uip tm report get --execution-id "$EXECUTION_ID" --project-key DEMO

# Script-friendly — JSON with just the counts
uip tm report get --execution-id "$EXECUTION_ID" --project-key DEMO \
  --query '{total: .TotalTests, passed: .Passed, failed: .Failed}'

Data エンベロープには次のフィールドがあります (完全なスキーマについては、report get の参照をご覧ください)。

  • TotalTestsPassedFailedSkippedPassRate ("80%")、 Duration (HH:MM:SS)。
  • FailedTests — 失敗したテスト ケースごとに 1 つのエントリ。 TestCaseNameError 文字列 (ログの info フィールド、または失敗したアサーション メッセージを連結したリスト) が含まれます。

CIのテストダッシュボードに取り込むことができるJUnit-XMLファイルが必要な場合は、report getの代わりに(または並行して)uip tm result downloadを使用します。

失敗したケースを CI ログに表示する

パイプラインを終了する前に、障害ごとに FailedTests 配列を人間が読める行に変換します。

if [ "$FAILED" -gt 0 ]; then
  uip tm report get \
    --execution-id "$EXECUTION_ID" \
    --project-key DEMO \
    --output-filter "Data.FailedTests[*].[TestCaseName, Error]" \
    --output plain >&2
  echo "$FAILED test case(s) failed" >&2
  exit 1
fi
if [ "$FAILED" -gt 0 ]; then
  uip tm report get \
    --execution-id "$EXECUTION_ID" \
    --project-key DEMO \
    --output-filter "Data.FailedTests[*].[TestCaseName, Error]" \
    --output plain >&2
  echo "$FAILED test case(s) failed" >&2
  exit 1
fi

より深い失敗分析 (失敗した 1uip tm testcaselogs list-assertions つのケースのアサーションごとの詳細) には、 によって返されるログ IDuip tm executions testcaselogs list --only-failed の を使用します。

不安定なケースをリトライする

実行に不安定なエラー (タイミング、環境) がある場合は、 失敗したケースのみを その場でリトライします。

uip tm executions retry \
  --execution-id "$EXECUTION_ID" \
  --project-key DEMO
uip tm executions retry \
  --execution-id "$EXECUTION_ID" \
  --project-key DEMO

uip tm executions retry同じ実行 ID が再利用され、新しい実行 ID は作成されません。再試行に失敗した場合は、情報メッセージを出力して 0 を終了します (意図的にエラーではありません)。

retry後、同じ実行 ID に対して wait + report get をループバックします。

よくある落とし穴

  • 出力 testsets run 解析して合格/不合格を決定します。起動時の [ Status ] フィールドは通常 Running です。これは、すべてのテストに合格したのではなく、実行がキューに置かれたことを意味します。必ず wait に電話してから report getに電話してください。
  • wait--timeoutを忘れる。既定値は 1800 秒 (30 分) です。無期限に待つために 0 を渡します(CIで望むことはめったにありません)。長いスイートの場合は、より大きな数を渡します。
  • wait からの終了2を認証エラーとして扱います。特にwaitでは、2AuthenticationErrorではなくタイムアウトを意味します - 終了コードuip tm waitを参照してください。
  • testsets動詞を使用してテストを作成する。テスト ケースおよびテスト ケースと Orchestrator のオートメーションへのリンクは uip tm testcasesに基づいています。testsetsそれらをグループ化するだけです。

完全な CI 対応の例

パイプライン ステップの bash スニペット — テストが失敗、タイムアウト、またはエラーが発生すると、ビルドに失敗します。

#!/usr/bin/env bash
set -euo pipefail

TEST_SET_KEY="${TEST_SET_KEY:?TEST_SET_KEY is required}"
PROJECT_KEY="${PROJECT_KEY:?PROJECT_KEY is required}"
TIMEOUT="${TEST_TIMEOUT:-1800}"

EXECUTION_ID=$(uip tm testsets run \
  --test-set-key "$TEST_SET_KEY" \
  --output-filter "Data.ExecutionId" \
  --output plain)

echo "started execution $EXECUTION_ID" >&2

if ! uip tm wait \
  --execution-id "$EXECUTION_ID" \
  --project-key "$PROJECT_KEY" \
  --timeout "$TIMEOUT"; then
  code=$?
  case "$code" in
    2) echo "execution $EXECUTION_ID did not finish within ${TIMEOUT}s" >&2; exit 2 ;;
    *) echo "wait failed with exit $code" >&2; exit "$code" ;;
  esac
fi

# Get the scorecard and the names of any failed cases in one shot
uip tm report get \
  --execution-id "$EXECUTION_ID" \
  --project-key "$PROJECT_KEY"

FAILED=$(uip tm report get \
  --execution-id "$EXECUTION_ID" \
  --project-key "$PROJECT_KEY" \
  --output-filter "Data.Failed" \
  --output plain)

if [ "$FAILED" -gt 0 ]; then
  echo "$FAILED test case(s) failed" >&2
  exit 1
fi

echo "all tests passed"
#!/usr/bin/env bash
set -euo pipefail

TEST_SET_KEY="${TEST_SET_KEY:?TEST_SET_KEY is required}"
PROJECT_KEY="${PROJECT_KEY:?PROJECT_KEY is required}"
TIMEOUT="${TEST_TIMEOUT:-1800}"

EXECUTION_ID=$(uip tm testsets run \
  --test-set-key "$TEST_SET_KEY" \
  --output-filter "Data.ExecutionId" \
  --output plain)

echo "started execution $EXECUTION_ID" >&2

if ! uip tm wait \
  --execution-id "$EXECUTION_ID" \
  --project-key "$PROJECT_KEY" \
  --timeout "$TIMEOUT"; then
  code=$?
  case "$code" in
    2) echo "execution $EXECUTION_ID did not finish within ${TIMEOUT}s" >&2; exit 2 ;;
    *) echo "wait failed with exit $code" >&2; exit "$code" ;;
  esac
fi

# Get the scorecard and the names of any failed cases in one shot
uip tm report get \
  --execution-id "$EXECUTION_ID" \
  --project-key "$PROJECT_KEY"

FAILED=$(uip tm report get \
  --execution-id "$EXECUTION_ID" \
  --project-key "$PROJECT_KEY" \
  --output-filter "Data.Failed" \
  --output plain)

if [ "$FAILED" -gt 0 ]; then
  echo "$FAILED test case(s) failed" >&2
  exit 1
fi

echo "all tests passed"

このスクリプトは、 いずれかの CI レシピのソリューションのデプロイ ステップの後に実行します。唯一の環境固有の設定は TEST_SET_KEY / PROJECT_KEY です — パイプライン内の環境ごとに設定し、同じスクリプトが dev/stage/prod 全体できれいにプロモートします。

参照

このページは役に立ちましたか?

接続

ヘルプ リソース サポート

学習する UiPath アカデミー

質問する UiPath フォーラム

最新情報を取得