テスト ケースのフィールド

テスト ケースのカスタム フィールドに関する情報を取得するには、次の API メソッドを使用します。  

get_case_fields

利用可能なテスト ケースのカスタム フィールドのリストを返します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
GET index.php?/api/v2/get_case_fields
GET index.php?/api/v2/get_case_fields
GET index.php?/api/v2/get_case_fields

レスポンスの内容

レスポンスにはカスタム フィールド定義の配列が含まれます。典型的なレスポンスについては、下記を参照してください。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[
{
"configs": [
{
"context": {
"is_global": true,
"project_ids": null
},
"id": "..",
"options": {
"default_value": "",
"format": "markdown",
"is_required": false,
"rows": "5"
}
}
],
"description": "The preconditions of this test case. ..",
"display_order": 1,
"id": 1,
"label": "Preconditions",
"name": "preconds",
"system_name": "custom_preconds",
"type_id": 3
},
..
]
[ { "configs": [ { "context": { "is_global": true, "project_ids": null }, "id": "..", "options": { "default_value": "", "format": "markdown", "is_required": false, "rows": "5" } } ], "description": "The preconditions of this test case. ..", "display_order": 1, "id": 1, "label": "Preconditions", "name": "preconds", "system_name": "custom_preconds", "type_id": 3 }, .. ]
[
    {
        "configs": [
            {
                "context": {
                    "is_global": true,
                    "project_ids": null
                },
                "id": "..",
                "options": {
                    "default_value": "",
                    "format": "markdown",
                    "is_required": false,
                    "rows": "5"
                }
            }
        ],
        "description": "The preconditions of this test case. ..",
        "display_order": 1,
        "id": 1,
        "label": "Preconditions",
        "name": "preconds",
        "system_name": "custom_preconds",
        "type_id": 3
    }, 
    ..
]

カスタム フィールドは、プロジェクトごとに異なる構成とオプションを持つ場合があり、それは configs フィールドによって示されます。カスタム フィールドが特定のプロジェクトに適用可能かどうかを確認する (そしてプロジェクトのフィールド オプションを取得する) には、フィールド設定の context をグローバル (is_global) にするか、project_ids にプロジェクトの ID を設定します。

また、次のリストは、利用可能なカスタム フィールドのタイプ (type_id) を示しています。

タイプ 名前
1 String
2 Integer
3 Text
4 URL
5 Checkbox
6 Dropdown
7 User
8 Date
9 Milestone
10 Steps
12 Multi-select

レスポンス コード

ステータス コード 説明
200 成功。利用可能なカスタム フィールドがレスポンスの一部として返されます

add_case_field

新規テスト ケース カスタム フィールドを作成します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
POST index.php?/api/v2/add_case_field
POST index.php?/api/v2/add_case_field
POST index.php?/api/v2/add_case_field

リクエスト フィールド

以下の POST フィールドがサポートされています (システムフィールド)。

名前 タイプ 必須 説明
type string true 新しいカスタム フィールドのタイプ識別子。以下のタイプがサポートされています。

    • String
    • Integer
    • Text
    • URL
    • Checkbox
    • Dropdown
    • User
    • Date
    • Milestone
    • Steps
    • Multiselect

タイプを表す数字のほか、名称の文字列を渡すこともできます。

例: “5”、”string”、”String”、”Dropdown”、”12″。

数字は文字列として送信する必要があります。

例: {type: 5} ではなく {type: “5”}。

さもないと 400 (Bad Request) レスポンスが返されます。

name string true 新しいカスタム フィールドの名前
label string true 新しいカスタム フィールドのラベル
description string false 新しいカスタム フィールドの説明
include_all boolean false 新しいカスタム フィールドをすべてのテンプレートに含める場合、true を設定します。それ以外の場合 (false)、次のパラメーター (template_ids) でカスタム フィールドを含めるテンプレートの ID を指定します。
template_ids array false include_all が false に設定されている場合、新しいカスタム フィールドが適用されるテンプレートの ID
configs object true 2つのデフォルトキー ‘context’ と ‘options’ を持つ配列でラップされたオブジェクト

新しいカスタム フィールドを作成するときは、 “custom_” 接頭辞は自動的に追加されるため、接頭辞のない名前だけを指定します。例えば、 “my_int” と指定すると、接頭辞が付加されて “custom_my_int” となります。

configs を持つカスタム フィールドには ‘context’ および ‘options’ デフォルト キーが必要です。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
"configs": [
{
"context":{"is_global": true, "project_ids": []},
"options":{"is_required": false, "default_value": "1", "items": "1, First\n2, Second"}
}
]
"configs": [ { "context":{"is_global": true, "project_ids": []}, "options":{"is_required": false, "default_value": "1", "items": "1, First\n2, Second"} } ]
"configs": [
    {
        "context":{"is_global": true, "project_ids": []},
        "options":{"is_required": false, "default_value": "1", "items": "1, First\n2, Second"}
    }
]

カスタム フィールドを特定のプロジェクトに適用するには、context を変更します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
"context": {"is_global": false, "project_ids": [5, 10]}
"context": {"is_global": false, "project_ids": [5, 10]}
"context": {"is_global": false, "project_ids": [5, 10]}

一部のカスタム フィールドタイプには異なるオプションがあります。“is_required” (ブール値) はすべてのフィールドに共通です。Multiselect、Milestone、Date 以外の型には、“default_value” を設定するオプションがあります。

Dropdown と Text には特別なオプションがあります。Dropdown 固有のオプションは items です。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
"items": "1, First\n2, Second"
"items": "1, First\n2, Second"
"items": "1, First\n2, Second"

Text の場合は、format と rows を使用します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
"format": "plain", "rows": "5"
"format": "plain", "rows": "5"
"format": "plain", "rows": "5"

“format” は、“plain” または “markdown” のどちらかの値を選択します。“rows” オプションは、ユーザーがフォームをロードしたときのフィールドの初期サイズを指定します。有効な値は、 “3”、“4”、…、 “10” などの値、または “” (空の文字列) です。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
"options": {
"is_required": false,
"default_value": "The default text.",
"format": "markdown",
"rows": "3"
}
"options": { "is_required": false, "default_value": "The default text.", "format": "markdown", "rows": "3" }
"options": {
    "is_required": false,
    "default_value": "The default text.",
    "format": "markdown",
    "rows": "3"
}

リクエストの例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
{
"type": "Multiselect",
"name": "my_multiselect",
"label": "My Multiselect",
"description": "my custom Multiselect description",
"configs": [
{
"context": {
"is_global": true,
"project_ids": ""
},
"options": {
"is_required": false,
"items": "1, One\n2, Two"
}
}
],
"include_all": true
}
{ "type": "Multiselect", "name": "my_multiselect", "label": "My Multiselect", "description": "my custom Multiselect description", "configs": [ { "context": { "is_global": true, "project_ids": "" }, "options": { "is_required": false, "items": "1, One\n2, Two" } } ], "include_all": true }
{
    "type": "Multiselect",
    "name": "my_multiselect",
    "label": "My Multiselect",
    "description": "my custom Multiselect description",
    "configs": [
        {
            "context": {
                "is_global": true,
                "project_ids": ""
            },
            "options": {
                "is_required": false,
                "items": "1, One\n2, Two"
            }
        }
    ],
    "include_all": true
}

レスポンスの内容

成功した場合、このメソッドは新しいカスタム フィールドを返します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
{
"id":33,
"name":"my_multiselect",
"system_name":"custom_my_multiselect",
"entity_id":1,
"label":"My Multiselect",
"description":"my custom Multiselect description",
"type_id":12,
"location_id":2,
"display_order":7,
"configs":"[{\"context\":{\"is_global\":true,\"project_ids\":\"\"},\"options\":{\"is_required\":false,\"items\":\"1, One\\n2, Two\"},\"id\":\"9f105ba2-1ed0-45e0-b459-18d890bad86e\"}]",
"is_multi":1,
"is_active":1,
"status_id":1,
"is_system":0,
"include_all":1,
"template_ids": []
}
{ "id":33, "name":"my_multiselect", "system_name":"custom_my_multiselect", "entity_id":1, "label":"My Multiselect", "description":"my custom Multiselect description", "type_id":12, "location_id":2, "display_order":7, "configs":"[{\"context\":{\"is_global\":true,\"project_ids\":\"\"},\"options\":{\"is_required\":false,\"items\":\"1, One\\n2, Two\"},\"id\":\"9f105ba2-1ed0-45e0-b459-18d890bad86e\"}]", "is_multi":1, "is_active":1, "status_id":1, "is_system":0, "include_all":1, "template_ids": [] }
{
    "id":33,
    "name":"my_multiselect",
    "system_name":"custom_my_multiselect",
    "entity_id":1,
    "label":"My Multiselect",
    "description":"my custom Multiselect description",
    "type_id":12,
    "location_id":2,
    "display_order":7,
    "configs":"[{\"context\":{\"is_global\":true,\"project_ids\":\"\"},\"options\":{\"is_required\":false,\"items\":\"1, One\\n2, Two\"},\"id\":\"9f105ba2-1ed0-45e0-b459-18d890bad86e\"}]",
    "is_multi":1,
    "is_active":1,
    "status_id":1,
    "is_system":0,
    "include_all":1,
    "template_ids": []
}

レスポンス コード

ステータス コード 説明
200 成功。新規カスタム フィールドがレスポンスの一部として返されます
400 不正なリクエスト。診断用のエラーメッセージを確認してください
404 見つからない、不適切なパラメータが渡されました