文档首页/ 测试计划 CodeArts TestPlan/ API参考/ API/ 接口测试管理/ 用例和用例脚本 - CreateTestCaseAndScriptTwo
更新时间:2025-12-27 GMT+08:00
分享

用例和用例脚本 - CreateTestCaseAndScriptTwo

功能介绍

根据工程唯一标识和用例脚本信息创建用例

调用方法

请参见如何调用API

URI

POST /v2/{project_id}/testcase

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释:

项目UUID,项目唯一标识,固定长度32位字符(字母和数字)。获取方式请参见获取项目ID

约束限制:

不涉及

取值范围:

项目uuid应符合如下规则:长度等于32位,包含大小写字母、数字

默认取值:

不涉及

表2 Query参数

参数

是否必选

参数类型

描述

iterator_uri

String

迭代uri

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

约束限制:

必传。

取值范围:

字符串长度不少于1,不超过10万。

默认取值:

不涉及。

表4 请求Body参数

参数

是否必选

参数类型

描述

CreateTestCaseAndScriptTwoRequestBody

String

用例脚本信息

响应参数

状态码:200

表5 响应Body参数

参数

参数类型

描述

error

CommonResponseErrorOfobject object

统一错误返回

reason

String

错误原因

result

Object

结果

status

String

'状态值,如success、error'

  • success,请求成功

  • error,请求报错

表6 CommonResponseErrorOfobject

参数

参数类型

描述

code

String

错误码

reason

String

错误原因

请求示例

"{
  "name": "TC_ZPduq",
  "script_name": "TC_ZPduq",
  "releaseDev": "",
  "tmss_case_uri": "",
  "activity_id": 1,
  "tmss_property": {
      "name": "TC_ZPduq",
      "description": "",
      "preparation": "",
      "steps": [
          {
              "testStep": "",
              "expectResult": ""
          }
      ],
      "number": "",
      "level": "2",
      "moduleId": "",
      "releaseDev": "",
      "releaseId": "",
      "ownerId": "",
      "test_type": 1,
      "labelId": [],
      "exe_platform": "apitest"
  },
  "import_info_list": [],
  "case_variable_list": [],
  "aw_instance": {
      "setup_aw_list": [],
      "test_aw_list": [],
      "teardown_aw_list": []
  },
  "source": "cloudtest"
}"

响应示例

状态码:200

SUCCESS

{
  "status" : "success",
  "result" : {
    "id" : "ff9f737472a14508a971192adba88299",
    "name" : "123",
    "deleteFlag" : null,
    "changeSign" : 0,
    "planId" : null,
    "issueId" : "",
    "addToPlan" : null,
    "releaseDev" : "",
    "copyFlag" : false,
    "source" : "cloudtest",
    "region" : "{region}",
    "status" : null,
    "create_time_string" : "2024-07-04 15:02:55 GMT+08:00",
    "update_time_string" : "2024-07-04 15:02:55",
    "create_time_stamp" : 1720076575000,
    "update_time_stamp" : 1720076575000,
    "create_user" : "devcloud_devcloud_s00314720_01",
    "create_time" : "2024-07-04T03:02:55+0800",
    "update_user" : "devcloud_devcloud_s00314720_01",
    "update_time" : "2024-07-04T03:02:55+0800",
    "tmss_property" : {
      "name" : "123",
      "description" : "",
      "number" : "102",
      "cataId" : null,
      "labelId" : [ ],
      "tags" : null,
      "level" : 2,
      "preparation" : "",
      "market" : null,
      "remark" : null,
      "originUri" : null,
      "releaseDev" : "",
      "stage" : null,
      "moduleId" : "",
      "releaseId" : "",
      "uri" : null,
      "node_name" : null,
      "test_type" : 1,
      "testStep" : null,
      "test_step" : null,
      "expectOutput" : null,
      "expect_output" : null,
      "env_type" : null,
      "exe_platform" : "apitest",
      "auto_type" : "1",
      "is_contract_testcase" : null,
      "is_paraValidator_testcase" : null,
      "test_feature" : null,
      "last_modified" : null,
      "last_modifier" : null,
      "author" : null,
      "creation_date" : null,
      "activity_id" : null,
      "owner" : null,
      "feature_path" : null,
      "ownerId" : "",
      "dr_relationid" : null,
      "applied_product" : null,
      "last_result" : null,
      "isKeyWord" : null,
      "steps" : [ {
        "testStep" : "",
        "expectResult" : ""
      } ],
      "networkScriptName" : null,
      "svnScriptPath" : null
    },
    "project_id" : "b7cb42f3fec14acba074624ddccd30db",
    "logic_case_id" : null,
    "activity_id" : "1",
    "package_name" : "scripts.user",
    "script_name" : "Case_ff9f737472a14508a971192adba88299_1",
    "script_path" : "src/scripts/user/Case_ff9f737472a14508a971192adba88299_1.java",
    "tmss_case_uri" : "v91k0000vm7tgc0c",
    "aw_instance" : {
      "setup_aw_list" : [ ],
      "test_aw_list" : [ ],
      "teardown_aw_list" : [ ]
    },
    "case_variable_list" : [ ],
    "quality_check_time" : null,
    "quality_check_result" : null,
    "tc_comments" : null,
    "import_info_list" : [ ],
    "IteratorCaseUri" : null,
    "IsKeyWord" : 0,
    "keyword_id" : null,
    "all_variable_names" : null,
    "variableGroupId" : null,
    "error_step" : null,
    "import_edit" : 5,
    "user_id" : null,
    "case_type" : 0
  },
  "reason" : null,
  "error" : null
}

状态码

状态码

描述

200

SUCCESS

错误码

请参见错误码

相关文档