测试用例管理
本主题页介绍如何使用 Codebeamer Swagger API 来管理测试。
本部分假定您已经
了解项目结构,并且熟悉
基本跟踪器项操作。
获取测试用例跟踪器
以下端点用于获取有关测试用例跟踪器的信息。测试用例跟踪器是类型为 Testcase 的特定跟踪器。除了下述某些特定字段外,此跟踪器的配置选项与其他跟踪器相同。
URL
GET /v3/trackers/{trackerId}
示例响应正文
{
"id": 2323,
"name": "Test Cases",
"description": "Test Cases",
"descriptionFormat": "Wiki",
"keyName": "TESTCASE",
"version": 1,
"createdAt": "2020-11-23T10:40:19.562",
"createdBy": {
"id": 1,
"name": "bond",
"type": "UserReference"
},
"type": {
"id": 102,
"name": "Testcase",
"type": "TrackerTypeReference"
},
"deleted": false,
"hidden": false,
"usingWorkflow": true,
"onlyWorkflowCanCreateNewReferringItem": false,
"usingQuickTransitions": false,
"defaultShowAncestorItems": false,
"defaultShowDescendantItems": false,
"project": {
"id": 4,
"name": "Intland Software's Scrum Template",
"type": "ProjectReference"
},
"availableAsTemplate": false
}
测试用例特定字段
“测试用例”类型的跟踪器中存在特定字段,即使项目管理员也无法修改这些字段的配置。
前置操作 | 此字段表示在执行测试之前需要执行的操作。此字段为基本的 Wiki 文本字段,其中包含图像、链接和特殊文本格式。 URL GET /v3/trackers/{trackerId}/fields/10000 示例响应正文 { "id": 10000, "name": "Pre-Action", "type": "WikiTextField", "hidden": false, "valueModel": "WikiTextFieldValue", "mandatoryInStatuses": [], "legacyRestName": "preAction" } |
后置操作 | 此字段表示在执行测试之后需要执行的操作。此字段为基本的 Wiki 文本字段,其中包含图像、链接和特殊文本格式。 URL GET /v3/trackers/{trackerId}/fields/10001 示例响应正文 { "id": 10000, "name": "Post-Action", "type": "WikiTextField", "hidden": false, "valueModel": "WikiTextFieldValue", "mandatoryInStatuses": [], "legacyRestName": "postAction" }, |
测试参数 | 可以对测试用例进行参数化,以使用不同的输入来运行同一测试用例。该测试用例采用的特殊格式如 测试参数化中所述。 URL GET /v3/trackers/{trackerId}/fields/10002 示例响应正文 { "id": 10002, "name": "Test Parameters", "type": "WikiTextField", "hidden": false, "valueModel": "WikiTextFieldValue", "mandatoryInStatuses": [], "legacyRestName": "testParameters" }, |
可复用 | URL GET /v3/trackers/{trackerId}/fields/10003 示例响应正文 { "id": 10003, "name": "Reusable", "type": "BoolField", "hidden": false, "valueModel": "BoolFieldValue", "mandatoryInStatuses": [ { "id": 0, "name": "Unset", "type": "ChoiceOptionReference" }, { "id": 1, "name": "New", "type": "ChoiceOptionReference" }, { "id": 2, "name": "In Design", "type": "ChoiceOptionReference" }, { "id": 3, "name": "Awaiting approval", "type": "ChoiceOptionReference" }, { "id": 4, "name": "Accepted", "type": "ChoiceOptionReference" }, { "id": 5, "name": "Rejected", "type": "ChoiceOptionReference" }, { "id": 6, "name": "Outdated", "type": "ChoiceOptionReference" } ], "legacyRestName": "reusable" } |
估计运行时间 | 此字段是简单的持续时间字段,其中包含要运行的测试的估计时间。 URL GET /v3/trackers/{trackerId}/fields/10004 示例响应正文 { "id": 10004, "name": "Estimated Run Time", "type": "DurationField", "hidden": false, "valueModel": "DurationFieldValue", "mandatoryInStatuses": [], "legacyRestName": "estimatedRunTime" } |
测试步骤 | 此表格字段用于说明测试运行期间必须执行的测试。这是测试用例中最重要的部分。 “测试步骤”字段包含三个可见列:“操作”、“预期结果”和“严重”。 Swagger API 中显示一个附加列:ID。如果要在其他测试用例中引用测试步骤,可以使用此值。 URL GET /v3/trackers/{trackerId}/fields/100000 示例响应正文 { "id": 1000000, "name": "Test Steps", "type": "TableField", "hidden": false, "valueModel": "TableFieldValue", "mandatoryInStatuses": [], "columns": [ { "id": 1000001, "name": "Action", "type": "WikiTextField", "hidden": false, "valueModel": "WikiTextFieldValue", "mandatoryInStatuses": [ { "id": 0, "name": "Unset", "type": "ChoiceOptionReference" }, { "id": 1, "name": "New", "type": "ChoiceOptionReference" }, { "id": 2, "name": "In Design", "type": "ChoiceOptionReference" }, { "id": 3, "name": "Awaiting approval", "type": "ChoiceOptionReference" }, { "id": 4, "name": "Accepted", "type": "ChoiceOptionReference" }, { "id": 5, "name": "Rejected", "type": "ChoiceOptionReference" }, { "id": 6, "name": "Outdated", "type": "ChoiceOptionReference" } ], "legacyRestName": "action" }, { "id": 1000002, "name": "Expected result", "type": "WikiTextField", "hidden": false, "valueModel": "WikiTextFieldValue", "mandatoryInStatuses": [], "legacyRestName": "expectedResult" }, { "id": 1000003, "name": "Critical", "type": "BoolField", "hidden": false, "valueModel": "BoolFieldValue", "mandatoryInStatuses": [], "legacyRestName": "critical" }, { "id": 1000004, "name": "Id", "type": "WikiTextField", "hidden": true, "valueModel": "WikiTextFieldValue", "mandatoryInStatuses": [], "legacyRestName": "id" } ], "legacyRestName": "testSteps" } |
获取测试用例信息
测试用例是基本的跟踪器项。通过以下端点获取存储的信息。
除了常用的跟踪器项值外,还可以获取特定测试用例字段值 (若已设置):
URL
GET /v3/items/{testCaseId}
示例响应正文
{
"id": 1133,
"name": "Simple Test case",
"description": "Simple Test case description",
...
"customFields": [
{
"fieldId": 10000,
"name": "Pre-Action",
"value": "Pre-action",
"type": "WikiTextFieldValue"
},
{
"fieldId": 10001,
"name": "Post-Action",
"value": "Post-action",
"type": "WikiTextFieldValue"
},
{
"fieldId": 10003,
"name": "Reusable",
"value": false,
"type": "BoolFieldValue"
},
{
"fieldId": 1000000,
"name": "Test Steps",
"values": [
[
{
"fieldId": 1000001,
"name": "Action",
"value": "Action 1",
"type": "WikiTextFieldValue"
},
{
"fieldId": 1000002,
"name": "Expected result",
"value": "Result 1",
"type": "WikiTextFieldValue"
},
{
"fieldId": 1000003,
"name": "Critical",
"value": false,
"type": "BoolFieldValue"
},
{
"fieldId": 1000004,
"name": "Id",
"value": "6cb707334c5297652fbe1a700cb4cb32",
"type": "WikiTextFieldValue"
}
],
[
{
"fieldId": 1000001,
"name": "Action",
"value": "Action 2",
"type": "WikiTextFieldValue"
},
{
"fieldId": 1000002,
"name": "Expected result",
"value": "Result 2",
"type": "WikiTextFieldValue"
},
{
"fieldId": 1000003,
"name": "Critical",
"value": false,
"type": "BoolFieldValue"
},
{
"fieldId": 1000004,
"name": "Id",
"value": "d544c916b3b22cbef43a0aadf48cc6fd",
"type": "WikiTextFieldValue"
}
]
],
"type": "TableFieldValue"
}
],
...
}
创建测试用例
要创建任何跟踪器项,必须针对跟踪器定义必填字段。
以下端点用于返回所有字段定义。必填字段的定义如
了解项目结构中所述。
URL
GET /v3/trackers/{trackerId}/schema
Agile Scrum 模板项目中的必填字段
优先级 | 示例请求正文 { "id": 2, "name": "Priority", "type": "OptionChoiceField", "hidden": false, "valueModel": "ChoiceFieldValue<ChoiceOptionReference>", "title": "P", "mandatoryInStatuses": [], "multipleValues": false, "options": [ { "id": 0, "name": "Unset", "type": "ChoiceOptionReference" }, { "id": 1, "name": "Highest", "type": "ChoiceOptionReference" }, { "id": 2, "name": "High", "type": "ChoiceOptionReference" }, { "id": 3, "name": "Normal", "type": "ChoiceOptionReference" }, { "id": 4, "name": "Low", "type": "ChoiceOptionReference" }, { "id": 5, "name": "Lowest", "type": "ChoiceOptionReference" } ], "legacyRestName": "priority", "trackerItemField": "priority", "referenceType": "ChoiceOptionReference" }, 此字段为内置字段,您可以直接设置其值。 示例请求正文 { "priority": { "id": 3, "name": "Normal", "type": "ChoiceOptionReference" }, } |
名称 | 示例请求正文 { "id": 3, "name": "Name", "type": "TextField", "hidden": false, "valueModel": "TextFieldValue", "mandatoryInStatuses": [ { "id": 0, "name": "Unset", "type": "ChoiceOptionReference" }, { "id": 1, "name": "New", "type": "ChoiceOptionReference" }, { "id": 2, "name": "In Design", "type": "ChoiceOptionReference" }, { "id": 3, "name": "Awaiting approval", "type": "ChoiceOptionReference" }, { "id": 4, "name": "Accepted", "type": "ChoiceOptionReference" }, { "id": 5, "name": "Rejected", "type": "ChoiceOptionReference" }, { "id": 6, "name": "Outdated", "type": "ChoiceOptionReference" } ], "legacyRestName": "name", "trackerItemField": "name" }, 此字段为内置字段,您可以直接设置其值。 示例请求正文 { "name": "Simple Test case", "priority": { "id": 3, "name": "Normal", "type": "ChoiceOptionReference" }, } |
状况 | 示例请求正文 { "id": 7, "name": "Status", "type": "OptionChoiceField", "hidden": false, "valueModel": "ChoiceFieldValue<ChoiceOptionReference>", "mandatoryInStatuses": [], "multipleValues": false, "options": [ { "id": 0, "name": "Unset", "type": "ChoiceOptionReference" }, { "id": 1, "name": "New", "type": "ChoiceOptionReference" }, { "id": 2, "name": "In Design", "type": "ChoiceOptionReference" }, { "id": 3, "name": "Awaiting approval", "type": "ChoiceOptionReference" }, { "id": 4, "name": "Accepted", "type": "ChoiceOptionReference" }, { "id": 5, "name": "Rejected", "type": "ChoiceOptionReference" }, { "id": 6, "name": "Outdated", "type": "ChoiceOptionReference" } ], "legacyRestName": "status", "trackerItemField": "status", "referenceType": "ChoiceOptionReference" }, 此字段为特殊字段,可以驱动许多其他功能,比如转变或权限。 如果只有一个转变来自清除状态,无论此字段为何,Codebeamer 都会自动使用目标状态。 要显式设置此字段,请使用以下示例。 示例请求正文 { "name": "Simple Test case", "priority": { "id": 3, "name": "Normal", "type": "ChoiceOptionReference" }, "status": { "id": 1, "name": "New", "type": "ChoiceOptionReference" }, "customFields": [ { "fieldId": 10003, "name": "Reusable", "value": false, "type": "BoolFieldValue" } ] } |
可复用 | 示例请求正文 { "id": 10003, "name": "Reusable", "type": "BoolField", "hidden": false, "valueModel": "BoolFieldValue", "mandatoryInStatuses": [ { "id": 0, "name": "Unset", "type": "ChoiceOptionReference" }, { "id": 1, "name": "New", "type": "ChoiceOptionReference" }, { "id": 2, "name": "In Design", "type": "ChoiceOptionReference" }, { "id": 3, "name": "Awaiting approval", "type": "ChoiceOptionReference" }, { "id": 4, "name": "Accepted", "type": "ChoiceOptionReference" }, { "id": 5, "name": "Rejected", "type": "ChoiceOptionReference" }, { "id": 6, "name": "Outdated", "type": "ChoiceOptionReference" } ], "legacyRestName": "reusable" }, 此字段为此特定跟踪器的自定义字段,因此,您必须使用 customFields 特性。 示例请求正文 { "name": "Simple Test case", "priority": { "id": 3, "name": "Normal", "type": "ChoiceOptionReference" }, "status": { "id": 1, "name": "New", "type": "ChoiceOptionReference" }, "customFields": [ { "fieldId": 10003, "name": "Reusable", "value": false, "type": "BoolFieldValue" } ] } |
发送创建请求
以下端点可用于发送创建请求。
URL
POST /v3/trackers/{trackerId}/items
示例请求正文
{
"name": "Simple Test case",
"priority": {
"id": 3,
"name": "Normal",
"type": "ChoiceOptionReference"
},
"status": {
"id": 1,
"name": "New",
"type": "ChoiceOptionReference"
},
"customFields": [
{
"fieldId": 10003,
"name": "Reusable",
"value": false,
"type": "BoolFieldValue"
}
]
}
为测试用例设置测试步骤
示例请求正文
添加测试步骤字段定义,如下所示:
{
"id": 1000000,
"name": "Test Steps",
"type": "TableField",
"hidden": false,
"valueModel": "TableFieldValue",
"mandatoryInStatuses": [],
"columns": [
{
"id": 1000001,
"name": "Action",
"type": "WikiTextField",
"hidden": false,
"valueModel": "WikiTextFieldValue",
"mandatoryInStatuses": [
{
"id": 0,
"name": "Unset",
"type": "ChoiceOptionReference"
},
{
"id": 1,
"name": "New",
"type": "ChoiceOptionReference"
},
{
"id": 2,
"name": "In Design",
"type": "ChoiceOptionReference"
},
{
"id": 3,
"name": "Awaiting approval",
"type": "ChoiceOptionReference"
},
{
"id": 4,
"name": "Accepted",
"type": "ChoiceOptionReference"
},
{
"id": 5,
"name": "Rejected",
"type": "ChoiceOptionReference"
},
{
"id": 6,
"name": "Outdated",
"type": "ChoiceOptionReference"
}
],
"legacyRestName": "action"
},
{
"id": 1000002,
"name": "Expected result",
"type": "WikiTextField",
"hidden": false,
"valueModel": "WikiTextFieldValue",
"mandatoryInStatuses": [],
"legacyRestName": "expectedResult"
},
{
"id": 1000003,
"name": "Critical",
"type": "BoolField",
"hidden": false,
"valueModel": "BoolFieldValue",
"mandatoryInStatuses": [],
"legacyRestName": "critical"
},
{
"id": 1000004,
"name": "Id",
"type": "WikiTextField",
"hidden": true,
"valueModel": "WikiTextFieldValue",
"mandatoryInStatuses": [],
"legacyRestName": "id"
}
],
"legacyRestName": "testSteps"
}
此字段为特定的表格字段,您必须将其设置为 customField,如下所示:
{
"name": "Simple Test case",
"priority": {
"id": 3,
"name": "Normal",
"type": "ChoiceOptionReference"
},
"status": {
"id": 1,
"name": "New",
"type": "ChoiceOptionReference"
},
"customFields": [
{
"fieldId": 10003,
"name": "Reusable",
"value": false,
"type": "BoolFieldValue"
},
{
"fieldId": 1000000,
"name": "Test Steps",
"values": [
[
{
"fieldId": 1000001,
"name": "Action",
"value": "Action 1",
"type": "WikiTextFieldValue"
},
{
"fieldId": 1000002,
"name": "Expected result",
"value": "Result 1",
"type": "WikiTextFieldValue"
},
{
"fieldId": 1000003,
"name": "Critical",
"value": false,
"type": "BoolFieldValue"
},
{
"fieldId": 1000004,
"name": "Id",
"value": "6cb707334c5297652fbe1a700cb4cb32",
"type": "WikiTextFieldValue"
}
],
[
{
"fieldId": 1000001,
"name": "Action",
"value": "Action 2",
"type": "WikiTextFieldValue"
},
{
"fieldId": 1000002,
"name": "Expected result",
"value": "Result 2",
"type": "WikiTextFieldValue"
},
{
"fieldId": 1000003,
"name": "Critical",
"value": false,
"type": "BoolFieldValue"
},
{
"fieldId": 1000004,
"name": "Id",
"value": "d544c916b3b22cbef43a0aadf48cc6fd",
"type": "WikiTextFieldValue"
}
]
],
"type": "TableFieldValue"
}
]
}
为测试用例设置引用的测试步骤
如果必须引用测试步骤,而不是从其他测试用例复制测试步骤,请在创建请求中使用 ReferredTestStepFieldValue 模型,如下所示。
示例请求正文
{
"fieldId": 1000004,
"name": "Id",
"referredStepId": "6cb707334c5297652fbe1a700cb4cb32",
"referredTestCaseId": 628791,
"type": "ReferredTestStepFieldValue"
}
三个主要特性如下:
◦ 使用 Test Steps 表格中 ID 字段的 fieldId。在默认配置中,它是 100004。
◦ referredTestCaseId 用于提供源测试用例项的 ID。
◦ referredStepId 必须在源测试用例引用的测试步骤行中包含 ID 字段值。
在测试步骤行中仅提供此值。
| 请不要提供 value 特性。由于需要一个新的测试步骤,为引用步骤生成 ID。 |
{
"name": "Referenced test steps",
"description": "",
"customFields": [
{
"fieldId": 1000000,
"name": "Test Steps",
"values": [
[
{
"fieldId": 1000004,
"name": "Id",
"referredStepId": "6cb707334c5297652fbe1a700cb4cb32",
"referredTestCaseId": 628791,
"type": "ReferredTestStepFieldValue"
}
],
[
{
"fieldId": 1000004,
"name": "Id",
"referredStepId": "d544c916b3b22cbef43a0aadf48cc6fd",
"referredTestCaseId": 628791,
"type": "ReferredTestStepFieldValue"
}
]
],
"type": "TableFieldValue"
}
]
}
测试运行跟踪器
测试用例跟踪器是类型为 Testcase 的特定跟踪器。除了下述某些特定字段外,此跟踪器的配置选项与其他跟踪器相同。
URL
GET /v3/trackers/{trackerId}
示例请求正文
{
"id": 2368,
"name": "Test Runs",
"description": "Test Run",
"descriptionFormat": "Wiki",
"keyName": "TESTRUN",
"version": 1,
"createdAt": "2020-11-23T10:40:19.562",
"createdBy": {
"id": 1,
"name": "bond",
"type": "UserReference"
},
"type": {
"id": 9,
"name": "Testrun",
"type": "TrackerTypeReference"
},
"deleted": false,
"hidden": false,
"usingWorkflow": true,
"onlyWorkflowCanCreateNewReferringItem": false,
"usingQuickTransitions": false,
"defaultShowAncestorItems": false,
"defaultShowDescendantItems": false,
"project": {
"id": 4,
"name": "Intland Software's Scrum Template",
"type": "ProjectReference"
},
"availableAsTemplate": false
}
测试运行特定字段
Testcase 类型的跟踪器中存在某些特定字段,即使项目管理员也无法修改这些字段的配置。
测试步骤结果
这是测试运行中最重要的部分。此表格字段包含运行测试期间的测试步骤结果。
“测试步骤结果”字段包含五列:“操作”、“预期结果”、“严重”、“实际结果”和“结果”。
URL
GET /v3/trackers/{trackerId}/fields/200000
示例请求正文
{
"id": 2000000,
"name": "Test Step Results",
"type": "TableField",
"hidden": false,
"valueModel": "TableFieldValue",
"mandatoryInStatuses": [],
"columns": [
{
"id": 2000001,
"name": "Action",
"type": "WikiTextField",
"hidden": false,
"valueModel": "WikiTextFieldValue",
"mandatoryInStatuses": [
{
"id": 0,
"name": "Unset",
"type": "ChoiceOptionReference"
},
{
"id": 1,
"name": "In progress",
"type": "ChoiceOptionReference"
},
{
"id": 2,
"name": "Suspended",
"type": "ChoiceOptionReference"
},
{
"id": 4,
"name": "Finished",
"type": "ChoiceOptionReference"
},
{
"id": 5,
"name": "To be approved",
"type": "ChoiceOptionReference"
},
{
"id": 6,
"name": "Ready for execution",
"type": "ChoiceOptionReference"
},
{
"id": 7,
"name": "Rejected",
"type": "ChoiceOptionReference"
},
{
"id": 8,
"name": "Closed",
"type": "ChoiceOptionReference"
}
],
"legacyRestName": "action"
},
{
"id": 2000002,
"name": "Expected result",
"type": "WikiTextField",
"hidden": false,
"valueModel": "WikiTextFieldValue",
"mandatoryInStatuses": [],
"legacyRestName": "expectedResult"
},
{
"id": 2000003,
"name": "Critical",
"type": "BoolField",
"hidden": false,
"valueModel": "BoolFieldValue",
"mandatoryInStatuses": [],
"legacyRestName": "critical"
},
{
"id": 2000004,
"name": "Actual result",
"type": "WikiTextField",
"hidden": false,
"valueModel": "WikiTextFieldValue",
"mandatoryInStatuses": [],
"legacyRestName": "actualResult"
},
{
"id": 2000005,
"name": "Result",
"type": "TextField",
"hidden": false,
"valueModel": "TextFieldValue",
"mandatoryInStatuses": [],
"legacyRestName": "result"
}
],
"legacyRestName": "testStepResults"
}
测试用例
此表格列包含相应的测试用例。
其中包含四列:“测试用例”、“已启用?”、“失效时停止?”和“结果”。
URL
GET /v3/trackers/{trackerId}/fields/100000
示例请求正文
{
"id": 1000000,
"name": "Test Cases",
"type": "TableField",
"hidden": false,
"valueModel": "TableFieldValue",
"mandatoryInStatuses": [
{
"id": 0,
"name": "Unset",
"type": "ChoiceOptionReference"
},
{
"id": 1,
"name": "In progress",
"type": "ChoiceOptionReference"
},
{
"id": 2,
"name": "Suspended",
"type": "ChoiceOptionReference"
},
{
"id": 4,
"name": "Finished",
"type": "ChoiceOptionReference"
},
{
"id": 5,
"name": "To be approved",
"type": "ChoiceOptionReference"
},
{
"id": 6,
"name": "Ready for execution",
"type": "ChoiceOptionReference"
},
{
"id": 7,
"name": "Rejected",
"type": "ChoiceOptionReference"
},
{
"id": 8,
"name": "Closed",
"type": "ChoiceOptionReference"
}
],
"columns": [
{
"id": 1000001,
"name": "Test Case",
"type": "TrackerItemChoiceField",
"hidden": false,
"valueModel": "ChoiceFieldValue",
"mandatoryInStatuses": [
{
"id": 0,
"name": "Unset",
"type": "ChoiceOptionReference"
},
{
"id": 1,
"name": "In progress",
"type": "ChoiceOptionReference"
},
{
"id": 2,
"name": "Suspended",
"type": "ChoiceOptionReference"
},
{
"id": 4,
"name": "Finished",
"type": "ChoiceOptionReference"
},
{
"id": 5,
"name": "To be approved",
"type": "ChoiceOptionReference"
},
{
"id": 6,
"name": "Ready for execution",
"type": "ChoiceOptionReference"
},
{
"id": 7,
"name": "Rejected",
"type": "ChoiceOptionReference"
},
{
"id": 8,
"name": "Closed",
"type": "ChoiceOptionReference"
}
],
"multipleValues": false,
"legacyRestName": "testCase",
"referenceType": "TrackerItemReference"
},
{
"id": 1000002,
"name": "Active",
"type": "BoolField",
"hidden": false,
"valueModel": "BoolFieldValue",
"mandatoryInStatuses": [],
"legacyRestName": "active"
},
{
"id": 1000003,
"name": "Stop on Failure",
"type": "BoolField",
"hidden": false,
"valueModel": "BoolFieldValue",
"mandatoryInStatuses": [],
"legacyRestName": "stopOnFailure"
},
{
"id": 1000004,
"name": "Result",
"type": "TextField",
"hidden": false,
"valueModel": "TextFieldValue",
"mandatoryInStatuses": [],
"legacyRestName": "result"
}
],
"legacyRestName": "testCases"
},
测试运行信息
示例响应正文
{
"id": 1137,
"name": "Quick Test Run for Simple Test case at Dec 15 2020",
"description": "",
"descriptionFormat": "Wiki",
"createdAt": "2020-12-15T14:14:33.566",
"createdBy": {
"id": 1,
"name": "bond",
"type": "UserReference"
},
"modifiedAt": "2020-12-15T14:14:33.566",
"modifiedBy": {
"id": 1,
"name": "bond",
"type": "UserReference"
},
"version": 1,
"assignedTo": [],
"tracker": {
"id": 2368,
"name": "Test Runs",
"type": "TrackerReference"
},
"children": [
{
"id": 1138,
"name": "Run of Simple Test case",
"type": "TrackerItemReference"
}
],
"customFields": [
{
"fieldId": 10000,
"name": "Sequential",
"value": false,
"type": "BoolFieldValue"
},
{
"fieldId": 10002,
"name": "Run only Accepted TestCases",
"value": false,
"type": "BoolFieldValue"
},
{
"fieldId": 1000000,
"name": "Test Cases",
"values": [
[
{
"fieldId": 1000001,
"name": "Test Case",
"values": [
{
"id": 1136,
"name": "Simple Test case",
"type": "TrackerItemReference"
}
],
"type": "ChoiceFieldValue"
}
]
],
"type": "TableFieldValue"
}
],
"priority": {
"id": 0,
"name": "Unset",
"type": "ChoiceOptionReference"
},
"status": {
"id": 6,
"name": "Ready for execution",
"type": "ChoiceOptionReference"
},
"platforms": [],
"subjects": [],
"resolutions": [],
"severities": [],
"formality": {
"id": 1,
"name": "Regular",
"type": "ChoiceOptionReference"
},
"versions": [
{
"id": 1002,
"name": "Sprint 1.2",
"type": "TrackerItemReference"
}
],
"ordinal": 0,
"typeName": "Testrun",
"comments": []
}
创建测试运行
• 使用专有端点
测试运行项层次结构复杂。该方法将接受测试集或测试用例列表,并创建以所有测试用例作为子项的测试运行。使用以下端点:
URL
POST /v3/trackers/{testRunTrackerId}/testruns
示例请求正文
{
"testCaseIds": [
{
"id": 1136,
"name": "Simple Test case",
"type": "TrackerItemReference"
},
{
"id": 1139,
"name": "Simple Test case 2",
"type": "TrackerItemReference"
}
]
}
结果
• 使用跟踪器项 API
我们已经掌握了创建新测试运行跟踪器项所需的全部信息,但在这种情况下,我们必须创建子结构。
每个测试用例都必须正确配置子测试运行。
设置测试运行结果
运行自动化测试后,可通过以下端点设置测试运行结果。
URL
PUT /v3/testruns/{testRunId}
示例请求正文
{
"updateRequestModels": [
{
"testCaseReference": {
"id": 1136,
"name": "Simple Test case",
"type": "TrackerItemReference"
},
"result": "PASSED",
"conclusion": "Successful run",
"runTime": 10
},
{
"testCaseReference": {
"id": 1139,
"name": "Simple Test case 2",
"type": "TrackerItemReference"
},
"result": "FAILED",
"conclusion": "Failed run",
"runTime": 20
}
],
"parentResultPropagation": true
}
结果