Performance Test-loadrunner JSON request for simulated rest interface

Source: Internet
Author: User

Now many mobile app performance tests, rest interface calls through the JSON format, when using LoadRunner to simulate these JSON requests, need to develop to provide

1, for the interface address

2. Submission method (get, post, put)

3, message body (message in LoadRunner encountered special characters note using escape)

After obtaining this information, we can use LoadRunner to simulate the request, the demo is as follows:

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;}

Performance Test-loadrunner JSON request for simulated rest interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.