简述:
Load Runner 测试Virtual User Generators生成
以及调用Load Runner Controller 进行测试
步骤:
1. 安装Load Runner
下载地址 http://download.csdn.net/detail/anialy/7514405
2. 打开HP Virtual User Generator
创建Web-HTTP/HTML
3. 进入脚本编辑页面
4. 点击编辑, 选中打开的浏览器,并进行录制
5. 完成后生成脚本
如果是做http接口测试,需要查看返回值, 则F4(Replay -> Run-Time Settings)
下面是网页请求的录制脚本,在应用cpa上运行
Action() { web_add_cookie("edu.yale.its.tp.cas.client.filter.receipt=53/50/49/53/53/51/53/124/69/48/48/50/51/48/49/56/54/124/; DOMAIN=127.0.0.1"); web_add_cookie("remoteuser=anialy; DOMAIN=127.0.0.1"); web_add_cookie("remoteuserid=123456; DOMAIN=127.0.0.1"); web_url("to_topic_page", "URL=http://127.0.0.1:8080/cpa/topic/student/to_topic_page?trainId=297ebd3045e0376f0145e0378a350000&topicCategory=0", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:8080/cpa/operation/common/home", "Snapshot=t6.inf", "Mode=HTML", EXTRARES, "Url=/cpa/common/static/lib/avatar_hover/image/topic/tck-1.gif", "Referer=http://127.0.0.1:8080/cpa/topic/student/to_topic_page?trainId=297ebd3045e0376f0145e0378a350000&topicCategory=0", ENDITEM, LAST); web_url("getTopicInfo", "URL=http://127.0.0.1:8080/cpa/topic/student/getTopicInfo?topicRelation=0&topicCategory=0&trainId=297ebd3045e0376f0145e0378a350000&userRoleCode=05&searchText=&_=1404108934867", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:8080/cpa/topic/student/to_topic_page?trainId=297ebd3045e0376f0145e0378a350000&topicCategory=0", "Snapshot=t7.inf", "Mode=HTML", EXTRARES, "Url=/cpa/static/student/face/emoji_86.png", "Referer=http://127.0.0.1:8080/cpa/topic/student/to_topic_page?trainId=297ebd3045e0376f0145e0378a350000&topicCategory=0", ENDITEM, LAST); return 0; }
如果是接口调用, 则录制脚本
Action() { web_custom_request("web_custom_request", "URL=http://nimeide.cn/searchPageService", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Mode=HTTP", "EncType=application/json", "Body=['param1','param2',{\"total_size\":0,\"page_size\":12,\"current_page\":1}]", LAST); return 0; }
6. 在Controller创建测试场景
tool -> create controller scenerio
于是进入Controller工具视图
脚本已经录入了,在Design面板的左下角,是对vuser数量渐增渐减的配置,
配置完成后,就可以进行录制了
完成后, 打开Run面板的结果,
可以看到Failed Transactions 为0, 那就都OK了