CreateTestCase - Create a test case
Applicable editions | Central edition, Region edition |
Endpoints and authorization
- Obtain an endpoint. Replace {domain} in the request syntax with the endpoint.
- Obtain a personal access token.
- Obtain an organization ID: Required only for the Central edition. Go to the organization management console and obtain the organization ID from the basic information page.
Product | Resource | Required permissions |
Test management | Test case | Read and write |
Request syntax
Central edition
POST https://{domain}/oapi/v1/testhub/organizations/{organizationId}/testRepos/{id}/testcases
Region edition
POST https://{domain}/oapi/v1/testhub/testRepos/{id}/testcases
Request header
Parameter | Type | Required | Description | Example value |
x-yunxiao-token | string | Yes | The personal access token. | pt-0fh3****0fbG_35af****0484 |
Request parameters
Parameter | Type | Location | Required | Description | Example value |
id | string | path | Yes | The ID of the test case repository. | |
organizationId | string | path |
| The organization ID. | |
| - | object | body | No | ||
| assignedTo | string | body | No | The owner. | user-id-xxx |
| customFieldValues | object | body | No | The custom field values. Call the GetTestcaseFieldConfig operation to obtain the field keys. | |
| directoryId | string | body | No | The ID of the folder. | dir-id-xxx |
| labels | array[string] | body | No | The label IDs. | |
| preCondition | string | body | No | The preconditions. By default, the value is processed as plain text and converted to rich text for storage. Line breaks in the text are converted to paragraphs. | The user is registered and logged on |
| preConditionFormat | string | body | No | The format of the preconditions. Valid values: RICHTEXT and TEXT. Default value: TEXT. TEXT: the value is processed as plain text. The server escapes HTML and converts line breaks to paragraphs. RICHTEXT: the value is already HTML and the server preserves it without escaping. | TEXT |
| subject | string | body | No | The title. | Verify that the logon feature is available |
| testSteps | object | body | No | ||
| content | array | body | No | The test step entries when contentType is set to TABLE. Write the expected result in the expected field of each entry. If contentType is set to TEXT and neither stepContent nor expectedResult is specified, the first entry is used as the test step and the expected result. | |
| - | object | body | No | ||
| expected | string | body | No | The expected result. | Expected result 1 |
| step | string | body | No | The test step. | Test step 1 |
| contentType | string | body | No | The content format. Valid values: TABLE and TEXT. | TEXT |
| expectedResult | string | body | No | The expected result when contentType is set to TEXT. In a request, pass plain text; the server converts it to rich text for storage. In a response, HTML content is returned. | Expected result 1 |
| stepContent | string | body | No | The test steps when contentType is set to TEXT. In a request, pass plain text; the server converts it to rich text for storage. In a response, HTML content is returned. If this parameter and content are both specified, this parameter takes precedence. | Test step 1 |
Request examples
Central edition
curl -X 'POST' \
'https://{domain}/oapi/v1/testhub/organizations/{organizationId}/testRepos/{id}/testcases' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"assignedTo": "user-id-xxx",
"customFieldValues": {
},
"directoryId": "dir-id-xxx",
"labels": [
],
"preCondition": "The user is registered and logged on",
"preConditionFormat": "TEXT",
"subject": "Verify that the logon feature is available",
"testSteps": {
"content": [
{
"expected": "Expected result 1",
"step": "Test step 1"
}
],
"contentType": "TEXT",
"expectedResult": "Expected result 1",
"stepContent": "Test step 1"
}
}'
Region edition
curl -X 'POST' \
'https://{domain}/oapi/v1/testhub/testRepos/{id}/testcases' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"assignedTo": "user-id-xxx",
"customFieldValues": {
},
"directoryId": "dir-id-xxx",
"labels": [
],
"preCondition": "The user is registered and logged on",
"preConditionFormat": "TEXT",
"subject": "Verify that the logon feature is available",
"testSteps": {
"content": [
{
"expected": "Expected result 1",
"step": "Test step 1"
}
],
"contentType": "TEXT",
"expectedResult": "Expected result 1",
"stepContent": "Test step 1"
}
}'
Response parameters
Parameter | Type | Description | Example value |
| - | object | ||
| id | string | The ID of the test case. | id-xxx |
Response example
{
"id": "id-xxx"
}
Error codes
For error codes, see the Error Code Center.