创建用例
功能介绍
创建用例
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
case_id |
否 |
Integer |
用例ID,通过“创建用例”接口获取响应体中的json.test_case_id字段的值。 |
|
name |
否 |
String |
用例名称 |
|
case_type |
否 |
Integer |
用例类型(0:常规用例;) |
|
contents |
否 |
Array of Contents objects |
用例脚本信息 |
|
for_loop_params |
否 |
Array of objects |
旧版本逻辑控制器字段,当前已未使用 |
|
increase_setting |
否 |
Array of objects |
梯度递增 |
|
stages |
否 |
Array of TestCaseStage objects |
阶段信息 |
|
status |
否 |
Integer |
状态,0:已删除;1:启用;2:禁用 |
|
temp_id |
否 |
Integer |
用例ID,通过“创建用例”接口获取响应体中的json.test_case_id字段的值。 |
|
sort |
否 |
Integer |
排序字段 |
|
directory_id |
否 |
Integer |
用例所属目录ID(旧版接口可不传) |
|
setup_contents |
否 |
Array of Contents objects |
前置步骤 |
|
user_replicas |
否 |
Integer |
执行器个数 |
|
collect_log_policy |
否 |
Integer |
日志采集策略(0-请求模式;1-用例模式) |
|
link_app_list |
否 |
Array of integers |
关联全链路应用列表 |
|
case_info |
否 |
CaseDoc object |
文本用例信息 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
operate_mode |
否 |
Integer |
压力阶段模式,0:时长模式;1:次数模式 |
|
name |
否 |
String |
阶段名称 |
|
time |
否 |
Integer |
压测时长(单位:秒) |
|
start_time |
否 |
Integer |
开始时间 |
|
end_time |
否 |
Integer |
结束时间 |
|
issue_num |
否 |
Integer |
最大并发数 |
|
count |
否 |
Integer |
次数模式发送总次数 |
|
pressure_mode |
否 |
Integer |
压力模式,0:并发模式;1:TPS模式;2:摸高模式;3:浪涌并发模式;4:浪涌TPS模式;5:震荡并发模式;6:震荡TPS模式;7:智能摸高模式 |
|
tps_value |
否 |
Integer |
TPS模式下TPS值 |
|
current_user_num |
否 |
Integer |
起始并发数 |
|
current_tps |
否 |
Integer |
起始TPS值 |
|
voltage_regulating_mode |
否 |
Integer |
调压模式,0:自动调压模式;1:手动调压模式 |
|
maximum |
否 |
Integer |
浪涌/浪涌模式下最大并发数 |
|
minimum |
否 |
Integer |
浪涌/浪涌模式下最小并发数 |
|
loop_count |
否 |
Integer |
震荡/浪涌次数 |
|
max_duration |
否 |
Integer |
浪涌模式下峰值持续时间 |
|
ramp_up |
否 |
Integer |
摸高模式下爬坡时长(单位:秒) |
|
peak_load_kpis |
否 |
StageKpiItems object |
摸高指标 |
|
step_duration |
否 |
Integer |
智能摸高模式下单步执行时长 |
|
step_size |
否 |
Integer |
智能摸高模式下递增并发数 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
average_response_time |
否 |
StageKpiItem object |
平均响应时间 |
|
success_rate |
否 |
StageKpiItem object |
成功率 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
content_id |
否 |
Integer |
事务ID,通过“创建事务”接口获取响应体中的tempId字段的值。若不为0表示此卡片为事务;为0表示非事务 |
|
content |
否 |
Array of Content objects |
内容 |
|
index |
否 |
Integer |
排序索引标识 |
|
selected_temp_name |
否 |
String |
选择的事务或者用例名称 |
|
data |
否 |
Object |
数据(循环、条件控制器作用的数据) |
|
data_type |
否 |
Integer |
数据指令类型(0:默认请求卡片;1:数据指令;201:循环指令;202:条件指令;301:集合点;203:vu百分比控制器;204:吞吐量控制器;302:插件请求) |
|
conditions |
否 |
Object |
若类型为202:条件指令,该字段为条件配置 |
|
is_disabled |
否 |
Boolean |
是否禁用 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
content_type |
否 |
Integer |
用例卡片类型(1:思考时间;2:报文;3:检查点;4:变量提取) |
|
content |
否 |
ContentInfo object |
内容 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
body_type |
否 |
Integer |
body类型(0:字符串;1:form-data格式;3:x-www-form-urlencoded格式) |
|
bodys |
否 |
Array of objects |
请求体 |
|
check_end_length |
否 |
Object |
TCP/UDP协议返回数据长度 |
|
check_end_str |
否 |
Object |
TCP/UDP协议返回结束符 |
|
check_end_type |
否 |
Object |
TCP/UDP协议返回结束类型,1:返回数据长度;2:结束符 |
|
connect_timeout |
否 |
Integer |
超时时间 |
|
connect_type |
否 |
Integer |
连接设置,当前版本已未使用 |
|
headers |
否 |
Array of ContentHeader objects |
请求头 |
|
http_version |
否 |
String |
HTTP版本 |
|
method |
否 |
String |
HTTP方法 |
|
name |
否 |
String |
用例名称 |
|
protocol_type |
否 |
Integer |
协议类型(1:HTTP;2:HTTPS;3:TCP;4:UDP;7:HLS/RTMP;9:WebSocket;10:HTTP-FLV;11:MQTT) |
|
return_timeout |
否 |
Integer |
响应超时 |
|
return_timeout_param |
否 |
String |
响应超时参数 |
|
url |
否 |
String |
请求地址 |
|
rtmp_url |
否 |
String |
rtmp地址 |
|
flv_url |
否 |
String |
flv地址 |
|
bitrate_type |
否 |
Integer |
分辨率策略 |
|
duration |
否 |
Integer |
持续时间 |
|
retry_delay |
否 |
Integer |
HLS重试延迟时间 |
|
retry_time |
否 |
Integer |
HLS重试次数 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
description |
否 |
String |
用例描述信息 |
|
label_names |
否 |
Array of strings |
标签 |
|
preparation |
否 |
String |
前置条件 |
|
rank |
否 |
Integer |
用例等级(0-L0;1-L1;2-L2;3-L3;4-L4;) |
|
status_code |
否 |
Integer |
状态(0-新建;5-设计中;6-测试中;7-完成;) |
|
steps |
否 |
Array of steps objects |
测试步骤 |
请求示例
创建一个用例,包括用例的请求信息,阶段信息等等。
/v2/{project_id}/test-cases
{
"name" : "new_case",
"case_type" : 0,
"setup_contents" : [ ],
"contents" : [ {
"content" : [ {
"content" : {
"body_type" : 0,
"bodys" : [ ],
"check_end_length" : null,
"check_end_str" : null,
"check_end_type" : null,
"connect_timeout" : 5000,
"connect_type" : 1,
"headers" : [ {
"key" : "Content-Type",
"value" : "application/json"
} ],
"http_version" : "HTTP/1.1",
"method" : "GET",
"name" : "request_example",
"protocol_type" : 1,
"return_timeout" : 5000,
"return_timeout_param" : null,
"url" : "http://117.xxx.xxx.xxx",
"duration" : 120,
"retry_delay" : 6000,
"retry_time" : 2
},
"content_type" : 2
} ],
"content_id" : 0,
"data" : null,
"data_type" : 0,
"index" : 0,
"conditions" : [ ],
"is_disabled" : false
} ],
"for_loop_params" : [ ],
"increase_setting" : [ ],
"stages" : [ {
"count" : 1,
"current_user_num" : 1,
"issue_num" : 1,
"name" : "Stage-2hih",
"operate_mode" : 0,
"pressure_mode" : 0,
"time" : 60,
"tps_value" : 1,
"voltage_regulating_mode" : 0,
"maximum" : 3,
"minimum" : 1,
"loop_count" : 2,
"max_duration" : 15,
"step_size" : 1,
"step_duration" : 30,
"ramp_up" : 30,
"peak_load_kpis" : {
"average_response_time" : {
"comparison" : "<=",
"value" : 60000
},
"success_rate" : {
"comparison" : ">=",
"value" : 0
}
}
} ],
"user_replicas" : 0,
"collect_log_policy" : 0,
"link_app_list" : [ ],
"case_id" : -1,
"sort" : 1,
"status" : 1,
"directory_id" : 174582,
"case_info" : {
"description" : "",
"label_names" : [ ],
"preparation" : "",
"rank" : 1,
"status_code" : 0,
"steps" : [ {
"expect_result" : "",
"test_step" : ""
} ]
},
"temp_id" : 0
}
响应示例
无
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
创建用例响应对象 |
错误码
请参见错误码。