LoadRunner使用教程

奋斗吧
奋斗吧
擅长邻域:未填写

标签: LoadRunner使用教程 博客 51CTO博客

2023-07-29 18:24:05 145浏览

LoadRunner使用教程,LoadRunner使用教程


1. LoadRunner简介

LoadRunner是一款广泛使用的性能测试工具

可以对各种应用程序进行性能测试,包括Web应用程序、移动应用程序、企业级应用程序等。它提供了一个综合的性能测试解决方案,包括测试计划设计、脚本录制、测试执行、结果分析和报告生成等功能。

主要有以下几个核心组件:

  1. Virtual User Generator(虚拟用户产生器):用于录制和编辑性能测试脚本。通过模拟用户的行为来捕获用户与应用程序之间的交互操作。
  2. Controller:用于设置测试场景和配置虚拟用户的行为。可以模拟不同的负载模式、并发用户数量和事务执行时间等。
  3. Load Generators:用于模拟实际用户的虚拟用户,并产生负载。可以在多台物理或虚拟机器上分布负载。
  4. Analysis:用于收集和分析测试执行期间的性能数据。提供图表、统计数据和报告,以便深入了解应用程序的性能状况。

2.Virtual User Generator基础使用

1.了解webtours系统

如何启动?

LoadRunner使用教程_应用程序

双击

LoadRunner使用教程_服务器_02

配置

有了ip还需要port才能访问成功,在配置文件中查看port

LoadRunner使用教程_服务器_03

LoadRunner使用教程_HTML_04

LoadRunner使用教程_loadrunner_05

2.脚本录制

打开VUG 

LoadRunner使用教程_loadrunner_06

 如何确定协议?找开发沟通

录制

LoadRunner使用教程_服务器_07

LoadRunner使用教程_loadrunner_08

 开始录制

LoadRunner使用教程_测试工具_09

LoadRunner使用教程_HTML_10

 有时需要将无关代码删除

3.编译

 

LoadRunner使用教程_HTML_11

LoadRunner使用教程_服务器_12

4.运行(回放)

LoadRunner使用教程_应用程序_13

打印日志: 

Virtual User Script started at : 2023/7/21 8:42:35
Starting action vuser_init.
Web Turbo Replay of LoadRunner 12.0.0 for Windows 8; build 2739 (Nov 30 2014 23:13:05)  	[MsgId: MMSG-27143]
Run mode: HTML  	[MsgId: MMSG-26993]
Run-Time Settings file: "C:\Users\陈昌良\Documents\VuGen\Scripts\WebHttpHtml1\\default.cfg"  	[MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Maximum number of concurrent connections per server: 6  	[MsgId: MMSG-26989]
Starting action Action.
Action.c(4): web_url("WebTours") started  	[MsgId: MMSG-26355]
Action.c(4): Detected non-resource "http://192.168.1.7:1080/WebTours/header.html" in "http://192.168.1.7:1080/WebTours/"  	[MsgId: MMSG-26574]
Action.c(4): Detected non-resource "http://192.168.1.7:1080/cgi-bin/welcome.pl?signOff=true" in "http://192.168.1.7:1080/WebTours/"  	[MsgId: MMSG-26574]
Action.c(4): Found resource "http://192.168.1.7:1080/WebTours/images/hp_logo.png" in HTML "http://192.168.1.7:1080/WebTours/header.html"  	[MsgId: MMSG-26659]
Action.c(4): Found resource "http://192.168.1.7:1080/WebTours/images/webtours.png" in HTML "http://192.168.1.7:1080/WebTours/header.html"  	[MsgId: MMSG-26659]
Action.c(4): Detected non-resource "http://192.168.1.7:1080/cgi-bin/nav.pl?in=home" in "http://192.168.1.7:1080/cgi-bin/welcome.pl?signOff=true"  	[MsgId: MMSG-26574]
Action.c(4): Detected non-resource "http://192.168.1.7:1080/WebTours/home.html" in "http://192.168.1.7:1080/cgi-bin/welcome.pl?signOff=true"  	[MsgId: MMSG-26574]
Action.c(4): Found resource "http://192.168.1.7:1080/WebTours/images/mer_login.gif" in HTML "http://192.168.1.7:1080/cgi-bin/nav.pl?in=home"  	[MsgId: MMSG-26659]
Action.c(4): web_url("WebTours") was successful, 10080 body bytes, 2371 header bytes, 24 chunking overhead bytes  	[MsgId: MMSG-26385]
Action.c(15): web_submit_form("login.pl") started  	[MsgId: MMSG-26355]
Action.c(15): Submitting form to "http://192.168.1.7:1080/cgi-bin/login.pl", Target Frame="body"  	[MsgId: MMSG-27978]
Action.c(15): Detected non-resource "http://192.168.1.7:1080/cgi-bin/nav.pl?username=Test&password=123456" in "http://192.168.1.7:1080/cgi-bin/login.pl"  	[MsgId: MMSG-26574]
Action.c(15): Detected non-resource "http://192.168.1.7:1080/cgi-bin/error.pl?error=badPassword" in "http://192.168.1.7:1080/cgi-bin/login.pl"  	[MsgId: MMSG-26574]
Action.c(15): Resource "http://192.168.1.7:1080/WebTours/images/mer_login.gif" is in the cache already and will not be downloaded again  	[MsgId: MMSG-26655]
Action.c(15): web_submit_form("login.pl") was successful, 2984 body bytes, 698 header bytes, 36 chunking overhead bytes  	[MsgId: MMSG-26385]
Action.c(26): web_submit_form("login.pl_2") started  	[MsgId: MMSG-26355]
Action.c(26): Submitting form to "http://192.168.1.7:1080/cgi-bin/login.pl", Target Frame="body"  	[MsgId: MMSG-27978]
Action.c(26): Detected non-resource "http://192.168.1.7:1080/cgi-bin/nav.pl?page=menu&in=home" in "http://192.168.1.7:1080/cgi-bin/login.pl"  	[MsgId: MMSG-26574]
Action.c(26): Detected non-resource "http://192.168.1.7:1080/cgi-bin/login.pl?intro=true" in "http://192.168.1.7:1080/cgi-bin/login.pl"  	[MsgId: MMSG-26574]
Action.c(26): Found resource "http://192.168.1.7:1080/WebTours/images/flights.gif" in HTML "http://192.168.1.7:1080/cgi-bin/nav.pl?page=menu&in=home"  	[MsgId: MMSG-26659]
Action.c(26): Found resource "http://192.168.1.7:1080/WebTours/images/itinerary.gif" in HTML "http://192.168.1.7:1080/cgi-bin/nav.pl?page=menu&in=home"  	[MsgId: MMSG-26659]
Action.c(26): Found resource "http://192.168.1.7:1080/WebTours/images/in_home.gif" in HTML "http://192.168.1.7:1080/cgi-bin/nav.pl?page=menu&in=home"  	[MsgId: MMSG-26659]
Action.c(26): Found resource "http://192.168.1.7:1080/WebTours/images/signoff.gif" in HTML "http://192.168.1.7:1080/cgi-bin/nav.pl?page=menu&in=home"  	[MsgId: MMSG-26659]
Action.c(26): web_submit_form("login.pl_2") was successful, 5780 body bytes, 2044 header bytes, 36 chunking overhead bytes  	[MsgId: MMSG-26385]
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.

 思考时间可以设置

LoadRunner使用教程_HTML_14

5.脚本增强

如何加强脚本

事务插入

函数:

lr_start_transcation("login")  开始事务  

lr_end_transaction("login", LR_AUTO);结束事务

LoadRunner使用教程_服务器_15

注意:事务必须有开始,有结束。缺一不可,会报错,名称也必须匹配

点击运行

LoadRunner使用教程_应用程序_16

事务的开始和结束

插入集合点

集合是什么?

在loadrunner为了达到并发这样的机制,引入了集合

让所有用户同时发起请求,等到所有用户都发出了,才向下执行脚本

lr_rendezvous("rendzous1"); 

LoadRunner使用教程_HTML_17

插入检查点

属于注册函数,需要放在URL之前才会生效,

函数:web_reg_find();

LoadRunner使用教程_服务器_18

 

LoadRunner使用教程_loadrunner_19

参数化

LoadRunner使用教程_应用程序_20

LoadRunner使用教程_测试工具_21

LoadRunner使用教程_HTML_22

 还可以添加参数

LoadRunner使用教程_loadrunner_23

LoadRunner使用教程_HTML_24

LoadRunner使用教程_HTML_25

LoadRunner使用教程_HTML_26

运行:

 

LoadRunner使用教程_测试工具_27

LoadRunner使用教程_服务器_28

打印相关日志

函数:lr_log_message("打印内容");

Action()
{

	web_url("WebTours", 
		"URL=http://192.168.1.7:1080/WebTours/", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t1.inf", 
		"Mode=HTML", 
		LAST);

	

	lr_think_time(15);

	lr_rendezvous("rendzous1");

	lr_start_transaction("login");
	//一百万用户到达这个点后才进行向下执行
	web_submit_form("login.pl", 
		"Snapshot=t2.inf", 
		ITEMDATA, 
		"Name=username", "Value=Test", ENDITEM, 
		"Name=password", "Value=123456", ENDITEM, 
		"Name=login.x", "Value=43", ENDITEM, 
		"Name=login.y", "Value=9", ENDITEM, 
		LAST);

	lr_think_time(7);

	lr_end_transaction("login", LR_AUTO);
	
	web_reg_find("Fail=NotFound",
		"Search=All",
		"SaveCount=",
		"Text=Welcome",
		LAST);
	

	web_submit_form("login.pl_2", 
		"Snapshot=t3.inf", 
		ITEMDATA, 
		"Name=username", "Value={username}", ENDITEM, 
		"Name=password", "Value={password}", ENDITEM, 
		"Name=login.x", "Value=51", ENDITEM, 
		"Name=login.y", "Value=5", ENDITEM, 
		LAST);
	
	lr_log_message("登录成功!");

	return 0;
}

LoadRunner使用教程_服务器_29

3.Controller的基础使用

Controller功能:用来设计测试场景

通过Controller设计简单的测试场景,简单的分析性能测试报告

Controlletonr打开方式:通过VUG打开或者双击直接打开

LoadRunner使用教程_loadrunner_30

LoadRunner使用教程_服务器_31

LoadRunner使用教程_测试工具_32

这种就是VUG打开,直接打开方式: 

LoadRunner使用教程_HTML_33

将左侧需要的导入点Ok即可

设置场景

LoadRunner使用教程_应用程序_34

LoadRunner使用教程_测试工具_35

 虚拟用户交流表

LoadRunner使用教程_loadrunner_36

开启这些服务 ,才能检测windows资源

LoadRunner使用教程_服务器_37

LoadRunner使用教程_服务器_38

添加监视 

LoadRunner使用教程_服务器_39

 

LoadRunner使用教程_应用程序_40

  

LoadRunner使用教程_loadrunner_41

运行场景

这里需要注意这个软件的BUG,需要点击view,show available graphs,然后点击右上方的  调整窗口大小  的按钮  才能显示出下列图表

LoadRunner使用教程_HTML_42

LoadRunner使用教程_loadrunner_43

一些放大图表 

LoadRunner使用教程_服务器_44

LoadRunner使用教程_loadrunner_45

4.Analysis基础使用

先勾选运行完场景后自动生成测试报告 

LoadRunner使用教程_loadrunner_46

将运行时间改短一些,然后运行等待,自动生成测试报告

分为两部分

汇总报告

LoadRunner使用教程_loadrunner_47

这是汇总报告,下面是图表

图表

LoadRunner使用教程_服务器_48

LoadRunner使用教程_应用程序_49

 

LoadRunner使用教程_HTML_50

 

LoadRunner使用教程_HTML_51

 

LoadRunner使用教程_测试工具_52

LoadRunner使用教程_服务器_53

 要查看其他指标的图,可以添加

LoadRunner使用教程_应用程序_54

添加虚拟用户汇总表

LoadRunner使用教程_loadrunner_55

LoadRunner使用教程_测试工具_56

 合并其他表(点击率和吞吐量) 

LoadRunner使用教程_服务器_57

 趋势大致相同,就没什么问题(点击在吞吐量之前,先请求才会有吞吐量。并且趋势大致相同 )

LoadRunner使用教程_测试工具_58

好博客就要一起分享哦!分享海报

此处可发布评论

评论(0展开评论

暂无评论,快来写一下吧

展开评论

您可能感兴趣的博客

客服QQ 1913284695