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