使用LoadRunner进行HTTP接口性能测试


测试接口:

接口一:http://127.0.0.1/API/GroupSearch?keyword=1988&userid=00001&page=1&pagesize=100 

接口二:http://127.0.0.1/Message/SyncMessage/SendMessage

A 使用Get请求访问接口一

Action()
{

    lr_start_transaction("API_Test1");

    web_reg_find("Text=message","Search=Body","SaveCount=Count",LAST);

    web_url("API_Test1", 
        "URL=http://127.0.0.1/API/GroupSearch?keyword={keyword}&userid=00001&page=1&pagesize=100",
        "Resource=0", 
        "RecContentType=text/html", 
        "Referer=", 
        "Snapshot=t2.inf", 
        "Mode=HTML",     
         LAST);

    lr_end_transaction("API_Test1",LR_AUTO);

    return 0;
}

 

B 使用Post请求访问接口二

Action()
{

    lr_start_transaction("API_Test2");

    web_add_header("accessToken","ZJ2mJZrRndC7/RvZOZ0DB4w/cTnN4xipkK2/oLZ3+sue/BKRwcH9TJ/e6cwOiGp8/7NZh7KWR+c67xbe8i+Qiw==");

    web_custom_request("API_Test2", 
        "URL=http://127.0.0.1/Message/SyncMessage/SendMessage",
        "Method=POST",               
        "Resource=0", 
        "RecContentType=application/json;charset=UTF-8",
        "Referer=", 
        "Snapshot=t2.inf", 
        "Mode=HTTP", 
        "EncType=application/json;charset=UTF-8",
        "Body={\"userID\":\"1234\",\"ContentType\":\"1000\"}",
         LAST);
lr_end_transaction(
"API_Test2",LR_AUTO); return 0; }

上述示例中,Post请求注意Body添加格式。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM