CreateTestCase

Updated at:

Create a test case in the use case library.

Operation description

When creating a test case in the use case library, you must use aliyunPk for user information.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST /organization/{organizationId}/testhub/testcase HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

organizationId

string

Yes

Get the organization ID from the URL of your Alibaba Cloud DevOps page, for example: https://devops.aliyun.com/organization/{organizationId}.

5ebbc0228123212b59xxxxx

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The request body.

subject

string

Yes

The title of the test case.

测试工作项

assignedTo

string

Yes

The ID of the assignee.

19xxxx31947xxxx

spaceIdentifier

string

Yes

The ID of the test case library.

asd345xxxxx9q9845xxxxx34

directoryIdentifier

string

Yes

The ID of the directory.

fdd395xxxxx9q9845xxxxx23

priority

string

No

The priority of the test case.

ik3dexxxxxfdfds1xxxxx23

tags

array

No

A list of tag IDs.

string

No

The ID of the tag.

opwxsxxxxxf5434xxxxx12

fieldValueList

array<object>

No

A list of custom fields.

object

No

Call the ListTestCaseAllFields operation to identify which custom fields are required. A field is required if its isRequired parameter is true.

fieldIdentifier

string

No

The ID of the field.

6aexxxxxa1d98c09c60xxxx16

value

string

No

The value of the field.

77c7fb03c4186c8691d6...

testcaseStepContentInfo

object

No

Contains the details of the test case steps.

precondition

string

No

The precondition for the test case.

前置条件内容

stepType

string

Yes

The format of the test step. Supported values are TABLE and TEXT.

Valid values:

  • TABLE :

    TABLE

  • TEXT :

    TEXT

TEXT

stepResultList

array<object>

No

A list of objects defining each test step and its expected result. If stepType is TEXT, only the first object is processed, and its content can be formatted. If stepType is TABLE, all objects are processed, but their content cannot be formatted.

object

No

The test step (step) and its expected result (expected).

step

string

No

The test step.

测试第一步骤

expected

string

No

The expected result.

测试第一步预期结果

Response elements

Element

Type

Description

Example

object

The response schema.

requestId

string

The ID of the request.

18E50717-93A4-53BC-A30D-963F742A1CE6

errorMsg

string

The error message.

error

errorCode

string

The error code.

""

success

boolean

Indicates whether the request was successful.

true

testcase

object

The test case object.

identifier

string

The ID of the test case.

5a73f81c834d013361d92bdcce

subject

string

The subject of the test case.

标题

assignedTo

object

Information about the assignee.

assignIdentifier

string

The ID of the assignee.

134xxx343xxxxx

name

string

The name of the assignee.

人员名称

tbRoleId

string

The ID of the user role.

3c2253c22xxxxxxxx53a

spaceIdentifier

string

The ID of the test case library.

a18571eba8fe9267cd8375fc06

spaceType

string

The type of the space. The value is always TestRepo.

TestRepo

categoryIdentifier

string

The ID of the work item type. The value is typically TestCase.

TestCase

creator

object

Information about the creator.

createIdentifier

string

The ID of the creator.

134xxx343xxxxx

name

string

The name of the creator.

人员名称

modifier

object

Information about the modifier.

modifyIdentifier

string

The ID of the modifier.

134xxx343xxxxx

name

string

The name of the modifier.

人员名称

directory

object

Information about the directory.

directoryIdentifier

string

The ID of the directory.

0bc1150dcxxxxxxxx04c

name

string

The name of the directory.

全部目录

pathName

array

The full directory path of the test case.

string

The sequence of directories in the path.

[一级目录,二级目录]

childIdentifier

string

The ID of the subdirectory.

0bc1150dcxxxxxxxx04c

detailInfo

object

Details of the test case.

stepType

string

The type of the test step. Valid values: TEXT, TABLE.

TEXT/TABLE

precondition

object

The precondition object.

preIdentifier

string

The ID of the precondition.

59253164xxxxxxf2e98dbc7e27

preContent

string

The content of the precondition.

前置条件内容

preContentType

string

The format of the precondition's content, such as RICHTEXT.

RICHTEXT

stepContent

object

The test step object.

stepIdentifier

string

The ID of the test step.

59253164xxxxxxf2e98dbc7e27

stepContent

string

The content of the test step.

测试步骤内容

stepContentType

string

The format of the test step's content, such as RICHTEXT.

RICHTEXT

expectedResult

object

The expected result object.

expectIdentifier

string

The ID of the expected result.

59253164xxxxxxf2e98dbc7e27

expectContent

string

The content of the expected result.

预期结果

expectContentType

string

The format of the expected result's content, such as RICHTEXT.

RICHTEXT

Examples

Success response

JSON format

{
  "requestId": "18E50717-93A4-53BC-A30D-963F742A1CE6",
  "errorMsg": "error",
  "errorCode": "\"\"",
  "success": true,
  "testcase": {
    "identifier": "5a73f81c834d013361d92bdcce",
    "subject": "标题",
    "assignedTo": {
      "assignIdentifier": "134xxx343xxxxx",
      "name": "人员名称",
      "tbRoleId": "3c2253c22xxxxxxxx53a"
    },
    "spaceIdentifier": "a18571eba8fe9267cd8375fc06",
    "spaceType": "TestRepo\n\n",
    "categoryIdentifier": "TestCase\n\n",
    "creator": {
      "createIdentifier": "134xxx343xxxxx",
      "name": "人员名称"
    },
    "modifier": {
      "modifyIdentifier": "134xxx343xxxxx",
      "name": "人员名称"
    },
    "directory": {
      "directoryIdentifier": "0bc1150dcxxxxxxxx04c",
      "name": "全部目录",
      "pathName": [
        "[一级目录,二级目录]"
      ],
      "childIdentifier": "0bc1150dcxxxxxxxx04c"
    },
    "detailInfo": {
      "stepType": "TEXT/TABLE",
      "precondition": {
        "preIdentifier": "59253164xxxxxxf2e98dbc7e27",
        "preContent": "前置条件内容",
        "preContentType": "RICHTEXT"
      },
      "stepContent": {
        "stepIdentifier": "59253164xxxxxxf2e98dbc7e27",
        "stepContent": "测试步骤内容",
        "stepContentType": "RICHTEXT"
      },
      "expectedResult": {
        "expectIdentifier": "59253164xxxxxxf2e98dbc7e27",
        "expectContent": "预期结果",
        "expectContentType": "RICHTEXT"
      }
    }
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 Openapi.RequestError request error
403 Operate.NoPermission NoPermission You are not authorized to perform this operation.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.