LoadRunner模拟REST接口的json请求
作者:网络转载 发布时间:[ 2015/5/12 13:42:22 ] 推荐标签:性能测试工具
现在很多手机应用的性能测试,REST接口调用通过json格式,在用loadrunner模拟这些json请求时,需要开发提供
1、供接口地址
2、提交方式(get、post、put)
3、消息体(消息在loadrunner里面遇到特殊字符注意使用转义)
获取这些信息后可以用loadrunner模拟请求了,demo如下:
Action()
{
lr_think_time(1);
lr_start_transaction("mnp_mock");
web_reg_save_param("response",
"LB=1.1",
"RB=OK",
"Ord=1",
"Search=ALL",
"Notfound=warning",
LAST);
web_custom_request("upload",
"URL=http://IP:port/api/api/v1/service/push",
"Method=POST",
"TargetFrame=",
"Resource=1",
"Referer=",
"Mode=HTML",
"EncType=application/json",
"Body={"messageID":{messageID},"groupID":null,"content":"redis putmessage1","remark":"20001remark","devices":[{"messageID":"{messageID}","userID":"{userID}","deviceID":"{deviceID}","deviceType":"{deviceType}","deviceToken":"admkmd121","deviceOS":"121os"},{"messageID":"{messageID}","userID":"{userID}","deviceID":"{deviceID}","deviceType":"{deviceType}","deviceToken":"admkmd122","deviceOS":"122os"}]}",
LAST);
if (atoi(lr_eval_string("{response}"))>0)
{
lr_end_transaction("mnp_mock",LR_PASS);
}
else
{
lr_end_transaction("mnp_mock",LR_FAIL);
//lr_error_message("%s",lr_eval_string("{response}"));
}
return 0;
}
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11