loadrunner 接口测试实例:天气接口,get&post
2017-06-10 22:03
465 查看
接口测试要点:
测试接口返回状态码
测试返回报文是否符合期望
get:
Action()
{
int HttpRetCode;
web_reg_save_param("ResponseBody", #用于传参
"LB=",
"RB=",
"Search=Body", LAST);
web_reg_find("Search=Body",#用于检查点
"SaveCount=",
"Text=西安",
LAST);
web_custom_request("web_custom_request",
"URL=http://www.weather.com.cn/data/sk/101110101.html",
"Method=GET",
"TargetFrame=",
"Resource=1",
"Referer=",
"Mode=HTTP",
"RecContentType=application/json",
"Body=",
LAST);
HttpRetCode=web_get_int_property(HTTP_INFO_RETURN_CODE);
if(HttpRetCode==200)
{ lr_output_message("成功!");
}
else
{ lr_output_message("失败!");
}
lr_output_message(lr_eval_string( "{ResponseBody}" ));
return 0;
}
post::
Action()
{
int HttpRetCode;
web_reg_save_param("ResponseBody",
"LB=",
"RB=",
"Search=Body", LAST);
web_custom_request("web_custom_request",
"URL=http://localhost:8000/post",
"Method=POST",
"TargetFrame=",
"Resource=1",
"Referer=",
"RecContentType=application/json",
"Mode=HTTP",
"Body=username=qitao&password=qt",
LAST);
HttpRetCode=web_get_int_property(HTTP_INFO_RETURN_CODE);
if(HttpRetCode==200)
{ lr_output_message("成功!");
}
else
{ lr_output_message("失败!");
}
lr_output_message(lr_eval_string( "{ResponseBody}" ));
return 0;
}
测试接口返回状态码
测试返回报文是否符合期望
get:
Action()
{
int HttpRetCode;
web_reg_save_param("ResponseBody", #用于传参
"LB=",
"RB=",
"Search=Body", LAST);
web_reg_find("Search=Body",#用于检查点
"SaveCount=",
"Text=西安",
LAST);
web_custom_request("web_custom_request",
"URL=http://www.weather.com.cn/data/sk/101110101.html",
"Method=GET",
"TargetFrame=",
"Resource=1",
"Referer=",
"Mode=HTTP",
"RecContentType=application/json",
"Body=",
LAST);
HttpRetCode=web_get_int_property(HTTP_INFO_RETURN_CODE);
if(HttpRetCode==200)
{ lr_output_message("成功!");
}
else
{ lr_output_message("失败!");
}
lr_output_message(lr_eval_string( "{ResponseBody}" ));
return 0;
}
post::
Action()
{
int HttpRetCode;
web_reg_save_param("ResponseBody",
"LB=",
"RB=",
"Search=Body", LAST);
web_custom_request("web_custom_request",
"URL=http://localhost:8000/post",
"Method=POST",
"TargetFrame=",
"Resource=1",
"Referer=",
"RecContentType=application/json",
"Mode=HTTP",
"Body=username=qitao&password=qt",
LAST);
HttpRetCode=web_get_int_property(HTTP_INFO_RETURN_CODE);
if(HttpRetCode==200)
{ lr_output_message("成功!");
}
else
{ lr_output_message("失败!");
}
lr_output_message(lr_eval_string( "{ResponseBody}" ));
return 0;
}
相关文章推荐
- Loadrunner 11 测试API java Vuser 模拟Post,Get 请求实例
- web接口测试之GET与POST请求
- Loadrunner测试json接口实例以及 web_custom_request 函数详解
- 【接口测试】:HttpClient Post 和 Get 请求
- 梦网云通讯获取API上行接口get_mo说明POST实例
- 在线HTTP POST/GET接口测试工具 - aTool在线工具
- web接口测试之GET与POST请求
- POSTMan接口测试之get post
- Loadrunner之HTTP接口测试脚本实例
- Linux 发送get和post请求测试接口
- 在线HTTP POST/GET接口测试工具 - aTool在线工具
- Android HTTP实例 使用GET方法和POST方法发送请求(通过Apache接口实现)
- web接口Flask测试之GET与POST请求
- 软件性能测试_loadrunner之web_custom_request函数做get接口测试
- 在线HTTP接口测试 - HTTP GET/POST模拟请求测试工具
- 个人写的http接口测试页面,支持post和get参数提交
- python3接口测试某个模块的很多接口有的用post有的用get
- 20161117移动端POST和GET接口的测试
- web接口测试GET与POST请求