您的位置:首页 > 其它

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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: