テスト結果に対してカスタマイズされた分析を実行したり、パーソナライズされたダッシュボードに他のデータと合わせてテスト結果を表示したりできると便利です。1 つまたは複数のテスト ランやテスト計画から、構造化された JSON フォーマットでテスト結果をエクスポートすることで、それが可能になります。
テスト ランおよびテスト結果の詳細を取得すると、強力な解析ツールでテスト作業に関する洞察を取得したり、外部ツールにテストの進捗を表示したりできます。たとえば、以下のようなことが可能です。
-
- BI ツールでテスト結果を解析します。
- 運用ダッシュボードにテスト結果を表示します。
テスト ランの取得
表示や任意の処理のために TestRail からテスト実行データを取得したい場合があるでしょう。テスト ランのセット内で成功したテストの数や失敗したテストの数など、テスト実行の概要だけが必要な場合は、下のようなリクエストを実行します。
リクエスト
GET index.php?/api/v2/get_runs/{project_id}
curl -X GET \ -u "user@example.com:password" \ "https://example.testrail.io/index.php?/api/v2/get_runs/27"
リクエスト ボディのサンプル
なし
レスポンス ボディのサンプル
{
"offset": 0,
"limit": 250,
"size": 250,
"_links": {
"next": "/api/v2/get_cases/1&limit=250&offset=250",
"prev": null
},
"runs": [
{
"id": 228,
"suite_id": 53,
"name": "New test run",
"description": "Test run description",
"milestone_id": null,
"assignedto_id": 5,
"include_all": false,
"is_completed": false,
"completed_on": 1684939401,
"config": null,
"config_ids": [],
"passed_count": 0,
"blocked_count": 0,
"untested_count": 1,
"retest_count": 0,
"failed_count": 2,
"custom_status1_count": 0,
"custom_status2_count": 0,
"custom_status3_count": 0,
"custom_status4_count": 0,
"custom_status5_count": 0,
"custom_status6_count": 0,
"custom_status7_count": 0,
"project_id": 27,
"plan_id": null,
"created_on": 1684936873,
"updated_on": 1684936873,
"refs": null,
"dataset_id": null,
"created_by": 18,
"url": "https://marketing80testing.testrail-staging.com/index.php?/runs/view/228"
}
]
}
クエリー パラメーターによるテスト結果のフィルタリング
-
- ID が 1 のプロジェクトの ID が 1 または 2 のユーザーによって作成されたすべてのアクティブなテスト ランを取得する場合:
GET index.php?/api/v2/get_runs/1&is_completed=0&created_by=1,2
- ID が 1 のプロジェクトの ID が 1 または 2 のユーザーによって作成されたすべてのアクティブなテスト ランを取得する場合:
テスト ランの結果の取得
すべてのテスト ケースの結果を解析し、洞察を得たい場合は、テスト ランごとに結果を取得できます。そうすると、テスト結果をより詳細に管理できます。
リクエスト
GET index.php?/api/v2/get_results_for_run/{run_id}
curl -X GET \ -u "user@example.com:password" \ "https://example.testrail.io/index.php?/api/v2/get_results_for_run/228"
リクエスト ボディのサンプル
なし
レスポンス ボディのサンプル
{
"offset": 0,
"limit": 250,
"size": 250,
"_links": {
"next": "/api/v2/get_results/42&limit=250&offset=250",
"prev": null
},
"results": [
{
"assignedto_id": 1,
"comment": "This test passed.",
"created_by": 1,
"created_on": 1393851801,
"custom_step_results": [],
"defects": "TR-1",
"elapsed": "5m",
"id": 801,
"status_id": 1,
"test_id": 91
},
{
"assignedto_id": 1,
"comment": "This test failed: ..",
"created_by": 1,
"created_on": 1393851801,
"custom_step_results": [],
"defects": "TR-1",
"elapsed": "3m",
"id": 802,
"status_id": 5,
"test_id": 92
}
]
}
クエリー パラメーターによるテスト結果のフィルタリング
-
- ID が 1 のテスト ランのユーザー 5 によって作成された最新 10 個の結果を取得する場合
GET index.php?/api/v2/get_results_for_run/1&created_by=5&limit=10
- ID が 1 のテスト ランのユーザー 5 によって作成された最新 10 個の結果を取得する場合