批量创建测试用例 - BatchCreateTestCasesAll
功能介绍
此接口用于批量创建测试用例,如测试设计归档用例.同页面 测试 -> 测试设计 -> 思维导图归档用例
调用方法
请参见如何调用API。
URI
POST /GT3KServer/v4/testcases/batch-add
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| project_uuid | 否 | String | 项目UUID,项目唯一标识,固定长度32位字符(字母和数字)。获取方式请参见获取项目ID |
| version_uri | 否 | String | 分支或者迭代uri |
| is_ignore | 否 | Boolean | 是否忽略异常 |
| test_case_infos | 是 | Array of CreateTestCaseInfo objects | 批量创建用例信息,单次最多创建20个用例 |
| import_test_case_num | 否 | Integer | ApiTest导入用例,分批调用接口时,首次调用接口,校验整个导入用例值,保持手工用例导入规则一致 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| steps | 否 | Array of TestCaseStepInfo objects | 测试步骤 |
| attachments | 否 | Array of TestCaseAttachmentInfo objects | 附件 |
| author | 否 | String | 创建人 |
| name | 是 | String | 名称 |
| rank | 否 | Integer | 用例等级 |
| owner | 否 | String | 处理人 |
| preparation | 否 | String | 前置条件 |
| remark | 否 | String | 备注 |
| stage | 否 | String | 测试阶段 |
| activity | 否 | String | 测试类型 |
| keywords | 否 | String | 关键词 |
| market | 否 | String | apitest标记是否代码已提交 |
| designer | 否 | String | 设计者 |
| tags | 否 | String | 标签 |
| region | 否 | String | 逻辑region,外部使用公有云实际区域,内部使用默认值 |
| uri | 否 | String | 测试用例Uri |
| relate_type | 否 | String | 参数解释: 关联资源类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
| service_type | 否 | Integer | 参数解释: 服务类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
| only_change_script | 否 | String | 关联资源类型只更新接口用例的java脚本路径标识 |
| add_to_iterator | 否 | String | 需求添加到迭代标识 |
| need_update_relation | 否 | String | 是否修改关联关系 |
| creation_version_uri | 否 | String | 创建版本Uri |
| number | 否 | String | 用例编号 |
| case_type | 否 | Integer | 参数解释: 用例类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
| platform_type | 否 | Integer | 执行平台类型 |
| test_type | 否 | Integer | 参数解释: 测试类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
| design_note | 否 | String | 设计描述 |
| test_step | 否 | String | 测试步骤 |
| expect_output | 否 | String | 期望结果 |
| env_type | 否 | String | 测试环境类型 |
| exe_platform | 否 | String | 执行平台 |
| testcase_project | 否 | String | 测试工程 |
| svn_script_path | 否 | String | 脚本路径 |
| map_restrict | 否 | String | 约束条件 |
| network_script_name | 否 | String | 网络脚本名 |
| auto_type | 否 | Integer | 自动化类型,非自动化:0, 是自动化:1 |
| to_be_auto_exec | 否 | Integer | 被自动化执行 |
| last_result | 否 | String | 最后一次结果 |
| last_result_uri | 否 | String | 最后一次结果Uri |
| feature_uri | 否 | String | 目录Uri |
| interface_name | 否 | String | 测试接口名 |
| snp_no | 否 | String | 网络问题ID |
| dr_relation_id | 否 | String | 关联需求编号 |
| test_base_num | 否 | String | 测试基数 |
| automatically_executed | 否 | Integer | 是否被自动化执行 |
| first_execute_time | 否 | String | 第一次执行时间 |
| detect_type | 否 | String | 检测类型 |
| execute_param | 否 | String | 执行参数 |
| test_feature | 否 | String | 分析领域 |
| is_contract_testcase | 否 | Integer | 是否是契约用例,0:表示非契约用例, 1:表示契约用例 |
| time_cost | 否 | Double | 总共耗时 |
| custom_field_1 | 否 | String | 自定义字段1 |
| custom_field_2 | 否 | String | 自定义字段2 |
| custom_field_3 | 否 | String | 自定义字段3 |
| custom_field_4 | 否 | String | 自定义字段4 |
| custom_field_5 | 否 | String | 自定义字段5 |
| custom_field_6 | 否 | String | 自定义字段6 |
| custom_field_7 | 否 | String | 自定义字段7 |
| custom_field_8 | 否 | String | 自定义字段8 |
| custom_field_9 | 否 | String | 自定义字段9 |
| custom_field_10 | 否 | String | 自定义字段10 |
| custom_field_11 | 否 | String | 自定义字段11 |
| custom_field_12 | 否 | String | 自定义字段12 |
| custom_field_13 | 否 | String | 自定义字段13 |
| custom_field_14 | 否 | String | 自定义字段14 |
| custom_field_15 | 否 | String | 自定义字段15 |
| custom_field_16 | 否 | String | 自定义字段16 |
| custom_field_17 | 否 | String | 自定义字段17 |
| custom_field_18 | 否 | String | 自定义字段18 |
| custom_field_19 | 否 | String | 自定义字段19 |
| custom_field_20 | 否 | String | 自定义字段20 |
| custom_field_21 | 否 | String | 自定义字段21 |
| custom_field_22 | 否 | String | 自定义字段22 |
| custom_field_23 | 否 | String | 自定义字段23 |
| custom_field_24 | 否 | String | 自定义字段24 |
| custom_field_25 | 否 | String | 自定义字段25 |
| be_auto_type_time | 否 | String | 记录用例由非自动化变为自动化类型的时间 |
| compare_number | 否 | String | 配对用例编号 |
| scene_flag | 否 | String | 场景标识 |
| base_flag | 否 | String | 场景标识 |
| para_validator | 否 | String | 区别是否从yaml中生成的用例,默认false |
| knet_node_id | 否 | String | knet节点id |
| last_exe_author | 否 | String | 最后一次执行用户 |
| cloud_carrier | 否 | String | 运营商 |
| market_place | 否 | String | 应用市场 |
| test_mind_id | 否 | String | 脑图id |
| test_mind_url | 否 | String | 脑图url |
| commit_url | 否 | String | git提交url |
| test_pattern_number | 否 | String | 测试模式编号 |
| test_factor_number | 否 | String | 测试因子编号 |
| status_code | 否 | String | 状态Code |
| result_code | 否 | String | 结果Code |
| release_id | 否 | String | 迭代ID |
| label_id | 否 | String | 标签ID |
| label_names | 否 | Array of strings | 用例操作时,标签名列表 |
| module_id | 否 | String | 模块ID |
| execute_latest_time | 否 | String | 最后执行时间 |
| execute_duration | 否 | String | 执行时长 |
| is_keyword | 否 | Integer | 是否关键用例 |
| release_dev | 否 | String | 测试版本号 |
| new_created | 否 | Integer | 是否用户新增用例 |
| execute_parameter | 否 | String | 执行参数 |
| project_id | 否 | String | 项目UUID,项目唯一标识,固定长度32位字符(字母和数字)。获取方式请参见获取项目ID |
| version_uri | 否 | String | 分支或者迭代uri |
| external_test_case_id | 否 | String | 外部用例id |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| test_step | 否 | String | 测试步骤 |
| expect_result | 否 | String | 预期结果 |
| step_actual | 否 | String | 步骤的实际结果 |
| step_result | 否 | String | 步骤结果 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| override | 否 | Boolean | 附件是否要被覆盖 |
| doc_id | 否 | String | 文档id |
| file_name | 否 | String | 文件名 |
| file_path | 否 | String | 文件路径 |
| file_type | 否 | String | 参数解释: 文件类型 约束限制: 根据文件后缀扩展名填入 取值范围:
等等 默认取值: 不涉及 |
| file_size | 否 | String | 文件大小 |
| override_id | 否 | String | 重复用例ID |
| related_type | 否 | String | 参数解释: 相关类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
| store_file_name | 否 | String | 保存文件名 |
| system_type | 否 | String | 参数解释: 系统区分 约束限制: 根据系统类型传入对应的值 取值范围:
默认取值: 不涉及 |
| storage_system | 否 | String | 区分文件存储系统 |
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| value | BatchCreateTestCaseVo object | 批量创建测试用例返回参数 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| success | Array of CreateTestCaseVo objects | 批量用例创建成功信息 |
| failed | Array of ValidateExceptionVo objects | 批量用例创建失败信息 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| uri | String | 资源URI |
| type | String | 参数解释: 资源类型 约束限制: 不涉及 取值范围:
默认取值: TestCase |
| author | String | 创建人 |
| name | String | 名称 |
| rank | Integer | 级别 |
| preparation | String | 前置条件 |
| remark | String | 备注 |
| stage | String | 测试阶段 |
| activity | String | 测试类型 |
| keywords | String | 关键词 |
| market | String | apitest标记是否代码已提交 |
| designer | String | 设计者 |
| tags | String | 标签 |
| execute_parameter | String | 执行参数 |
| region | String | 逻辑region |
| owner | String | 处理人id,IteratorTestCase字段 |
| last_modifier | String | 最后修改人 |
| last_modified | String | 最后修改时间 |
| last_modified_timestamp | Long | 修改时间时间戳 |
| last_change_time | String | 最后变更时间 |
| version_uri | String | 版本URI |
| origin_uri | String | 源资源URI |
| parent_uri | String | 父资源URI |
| parent_path | String | 父资源路径 |
| creation_version_uri | String | 创建版本URI |
| creation_date | String | 创建时间 |
| creation_date_timestamp | Long | 创建时间时间戳 |
| author_name | String | 创建人名称 |
| comment | String | 备注 |
| number | String | 编号 |
| case_type | Integer | 参数解释: 用例类型 取值范围:
|
| platform_type | Integer | 执行平台类型 |
| service_type | Integer | 参数解释: 服务类型 取值范围:
|
| service_type_name | String | 服务类型名称 |
| test_type | Integer | 参数解释: 测试类型 取值范围:
|
| test_type_name | String | 测试类型名称 |
| design_note | String | 设计描述 |
| test_step | String | 测试步骤 |
| expect_output | String | 期望结果 |
| env_type | String | 测试环境类型 |
| exe_platform | String | 执行平台 |
| testcase_project | String | 测试工程 |
| svn_script_path | String | 脚本路径 |
| map_restrict | String | 约束条件 |
| network_script_name | String | 网络脚本名 |
| auto_type | Integer | 自动化类型,非自动化:0, 是自动化:1 |
| to_be_auto_exec | Integer | 被自动化执行 |
| last_result | String | 最后一次结果 |
| last_result_uri | String | 最后一次结果Uri |
| feature_uri | String | 目录Uri |
| feature_name | String | 目录名称 |
| interface_name | String | 测试接口名 |
| snp_no | String | 网络问题ID |
| dr_relation_id | String | 关联需求编号 |
| issue_name | String | 需求名称 |
| test_base_num | String | 测试基数 |
| automatically_executed | Integer | 是否被自动化执行 |
| first_execute_time | String | 第一次执行时间 |
| detect_type | String | 检测类型 |
| execute_param | String | 执行参数 |
| test_feature | String | 分析领域 |
| is_contract_testcase | Integer | 是否是契约用例,0:表示非契约用例, 1:表示契约用例 |
| time_cost | Double | 总共耗时 |
| be_auto_type_time | String | 记录用例由非自动化变为自动化类型的时间 |
| compare_number | String | 配对用例编号 |
| scene_flag | String | 场景标识 |
| base_flag | String | 场景标识 |
| para_validator | String | 区别是否从yaml中生成的用例,默认false |
| knet_node_id | String | knet节点id |
| last_exe_author | String | 最后一次执行用户 |
| cloud_carrier | String | 运营商 |
| market_place | String | 应用市场 |
| test_mind_id | String | 脑图id |
| test_mind_url | String | 脑图url |
| commit_url | String | git提交url |
| test_pattern_number | String | 测试模式编号 |
| test_factor_number | String | 测试因子编号 |
| status_code | String | 状态Code |
| result_code | String | 结果Code |
| release_id | String | 迭代ID |
| label_id | String | 标签ID |
| labels | String | 用例标签名称列表 |
| module_id | String | 模块ID |
| module_name | String | 模块名称 |
| module_path | String | 模块path |
| module_path_name | String | 模块路径名称 |
| execute_latest_time | String | 最后执行时间 |
| execute_duration | String | 执行时长 |
| execute_times | Integer | 执行次数 |
| is_keyword | Integer | 是否关键用例 |
| release_dev | String | 测试版本号 |
| new_created | String | 是否用户新增用例 |
| project_id | String | 项目UUID,项目唯一标识,固定长度32位字符(字母和数字)。获取方式请参见获取项目ID |
| creation_version_name | String | 创建版本名称,原逻辑marshall添加字段 |
| feature_path | String | 特性路径,原逻辑marshall添加字段 |
| testcase_uri | String | 实体用例Uri,IteratorTestCase字段 |
| owner_name | String | 处理人名称 |
| iterator_case_uri | String | 迭代用例Uri,IteratorTestCase字段 |
| script_link | String | 脚本链接scriptLink |
| custom_field_1 | String | 自定义字段1 |
| custom_field_2 | String | 自定义字段2 |
| custom_field_3 | String | 自定义字段3 |
| custom_field_4 | String | 自定义字段4 |
| custom_field_5 | String | 自定义字段5 |
| custom_field_6 | String | 自定义字段6 |
| custom_field_7 | String | 自定义字段7 |
| custom_field_8 | String | 自定义字段8 |
| custom_field_9 | String | 自定义字段9 |
| custom_field_10 | String | 自定义字段10 |
| custom_field_11 | String | 自定义字段11 |
| custom_field_12 | String | 自定义字段12 |
| custom_field_13 | String | 自定义字段13 |
| custom_field_14 | String | 自定义字段14 |
| custom_field_15 | String | 自定义字段15 |
| custom_field_16 | String | 自定义字段16 |
| custom_field_17 | String | 自定义字段17 |
| custom_field_18 | String | 自定义字段18 |
| custom_field_19 | String | 自定义字段19 |
| custom_field_20 | String | 自定义字段20 |
| custom_field_21 | String | 自定义字段21 |
| custom_field_22 | String | 自定义字段22 |
| custom_field_23 | String | 自定义字段23 |
| custom_field_24 | String | 自定义字段24 |
| custom_field_25 | String | 自定义字段25 |
| external_test_case_id | String | 外部用例id |
| project_uuid | String | 项目id |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| external_testcase_id | String | 外部用例id,用于apitest匹配错误用例 |
| error_content | String | 错误信息的唯一标识,取决于错误记录中哪个字段可以直观体现是哪个错误记录 |
| error_field | String | 错误字段 |
| error_msg | String | 错误内容 |
| error_code | String | 错误码 |
状态码:400
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 接口调用失败错误码 |
| error_msg | String | 接口调用失败错误信息 |
状态码:401
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 接口调用失败错误码 |
| error_msg | String | 接口调用失败错误信息 |
状态码:404
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 接口调用失败错误码 |
| error_msg | String | 接口调用失败错误信息 |
状态码:500
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 接口调用失败错误码 |
| error_msg | String | 接口调用失败错误信息 |
请求示例
post https://{endpoint}/GT3KServer/v4/testcases/batch-add
{
"version_uri" : "v90200010aelu5om",
"test_case_infos" : [ {
"steps" : [ {
"test_step" : "",
"expect_result" : ""
} ],
"test_mind_id" : "41047aa57b6246fd97b8cdf049e17c86",
"name" : "sdsdsdsd",
"rank" : "2",
"preparation" : "",
"remark" : "",
"service_type" : "0",
"external_test_case_id" : "C2E9C88A7E194490A0750AF5ED93811B",
"feature_uri" : "407ac57de7ea44d28e47293a2b9cf15c",
"owner" : "2ce06fffb4634271a377c1cd7c429704",
"relate_type" : "requirement"
} ]
} 响应示例
状态码:200
OK
{
"value" : {
"success" : [ {
"uri" : "v90100010i5o9atn",
"type" : "TestCase",
"author" : "2ce06fffb4634271a377c1cd7c429704",
"name" : "sdsdsdsd",
"rank" : 2,
"stage" : "1",
"designer" : "2ce06fffb4634271a377c1cd7c429704",
"region" : "roma-dev-2-arm",
"owner" : "2ce06fffb4634271a377c1cd7c429704",
"last_modifier" : "2ce06fffb4634271a377c1cd7c429704",
"last_modified" : "2025-06-16 18:17:04",
"last_change_time" : "2025-06-16 18:17:04",
"version_uri" : "v90200010aelu5om",
"parent_uri" : "v90200010aelu5om",
"parent_path" : "/407ac57de7ea44d28e47293a2b9cf15c/v90200010aelu5om/",
"creation_date" : "2025-06-16 18:17:04",
"number" : "7428",
"case_type" : 0,
"platform_type" : 0,
"service_type" : 0,
"test_type" : 0,
"external_test_case_id" : "C2E9C88A7E194490A0750AF5ED93811B",
"test_step" : "[\"\"]",
"expect_output" : "[\"\"]",
"auto_type" : 0,
"to_be_auto_exec" : 0,
"automatically_executed" : 0,
"is_contract_testcase" : 0,
"time_cost" : 0,
"test_mind_id" : "41047aa57b6246fd97b8cdf049e17c86",
"status_code" : "0",
"execute_times" : 0
} ],
"failed" : [ ]
}
} 状态码
| 状态码 | 描述 |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 401 | Unauthorized |
| 404 | Not Found |
| 500 | Internal Server Error |
错误码
请参见错误码。