camily 2008-4-2 15:29
JMeter安装与简单操作
[size=1][font=宋体][/font][/size]
[size=10.5pt][/size]
[size=2][font=黑体][size=1]这几天在用Jmeter,将本人的学习成果与大家共享一下,希望大家多多交流,提出问题[img]http://www.51testing.com/images/edit/face/001.gif[/img][/size][/font][/size]
[size=2][font=黑体]简介[/font][/size]
[font=宋体][size=10.5pt]• [/size][/font][size=10.5pt]JMeter[/size][font=宋体][size=10.5pt]是[/size][/font][size=10.5pt]Apache[/size][font=宋体][size=10.5pt]软件基金会的产品,它是一个[/size][/font][size=10.5pt]100%[/size][font=宋体][size=10.5pt]纯[/size][/font][size=10.5pt]java[/size][font=宋体][size=10.5pt]桌面应用程序,被设计用来测试客户端[/size][/font][size=10.5pt]/[/size][font=宋体][size=10.5pt]服务器结构的软件(例如[/size][/font][size=10.5pt]web[/size][font=宋体][size=10.5pt]应用程序)。它可以用来测试包括基于静态和动态资源程序的性能,例如静态文件,[/size][/font][size=10.5pt]Java Servlets[/size][font=宋体][size=10.5pt],[/size][/font][size=10.5pt]Java [/size][font=宋体][size=10.5pt]对象,数据库,[/size][/font][size=10.5pt]FTP [/size][font=宋体][size=10.5pt]服务器等等。[/size][/font][size=10.5pt]JMeter[/size][font=宋体][size=10.5pt]可以用来在一个服务器、网络或者对象上模拟重负载来测试它的强度或者分析在不同的负载类型下的全面性能。[/size][/font][size=10.5pt][/size]
[font=宋体][size=10.5pt]• [/size][/font][font=宋体][size=10.5pt]另外,[/size][/font][size=10.5pt]JMeter[/size][font=宋体][size=10.5pt]提供一个基于[/size][/font][size=10.5pt]GUI[/size][font=宋体][size=10.5pt]的应用程序,用于设计和执行多种可重用的测试计划。它还支持以[/size][/font][size=10.5pt]XML[/size][font=宋体][size=10.5pt]格式捕捉测试结果,用于测试后的统计分析。[/size][/font][size=10.5pt][/size]
[size=10.5pt] [/size]
[size=10.5pt] [/size]
[size=2][font=黑体]安装[/font][/size]
[font=宋体][size=10.5pt]• [/size][/font][font=宋体][size=10.5pt]安装[/size][/font][size=10.5pt]JDK
[/size][font=宋体][size=10.5pt]设置环境变量:右击我的电脑[/size][/font][size=10.5pt]->[/size][font=宋体][size=10.5pt]高级[/size][/font][size=10.5pt]->[/size][font=宋体][size=10.5pt]环境变量[/size][/font][size=10.5pt]->[/size][font=宋体][size=10.5pt]系统变量,在系统变量框里做如下工作:[/size][/font][size=10.5pt]
[/size][font=宋体][size=10.5pt]新建变量[/size][/font][size=10.5pt]JAVA_HOME[/size][font=宋体][size=10.5pt],值为:安装[/size][/font][size=10.5pt]JDK[/size][font=宋体][size=10.5pt]的目录[/size][/font][size=10.5pt]
[/size][font=宋体][size=10.5pt]新建变量[/size][/font][size=10.5pt]CLASSPATH[/size][font=宋体][size=10.5pt],值为:[/size][/font][size=10.5pt]%JAVA_HOME\lib
[/size][font=宋体][size=10.5pt]在[/size][/font][size=10.5pt]path[/size][font=宋体][size=10.5pt]变量后加上:[/size][/font][size=10.5pt]%JAVA_HOME\lib
[/size][font=宋体][size=10.5pt]在命令提示符窗口中输入:[/size][/font][size=10.5pt]JAVA[/size][font=宋体][size=10.5pt]或[/size][/font][size=10.5pt]JAVAC[/size][font=宋体][size=10.5pt],如果出现帮助信息,则[/size][/font][size=10.5pt]JDK[/size][font=宋体][size=10.5pt]安装成功[/size][/font][size=10.5pt][/size]
[size=10.5pt] [/size]
[font=宋体][size=10.5pt]• [/size][/font][font=宋体][size=2]安装[/size][/font][size=2]JMeter
[font=宋体]下载[/font]JMeter[font=宋体]安装包,如果安装包是压缩文件,直接解压缩到安装目录就可以使用[/font]JMeter[size=10.5pt][/size][/size]
[size=2][font=黑体]基本应用[/font][/size]
[size=3][size=5]1[font=宋体].打开基于图型界面的[/font]JMeter[font=宋体]:[/font][/size][/size]
[font=宋体][size=10.5pt]方法:在[/size][/font][size=10.5pt]JMeter[/size][font=宋体][size=10.5pt]的[/size][/font][size=10.5pt]bin[/size][font=宋体][size=10.5pt]目录下找到[/size][/font][size=10.5pt]jmeter.bat[/size][font=宋体][size=10.5pt]批处理文件,双击打开[/size][/font]
[font=宋体][size=10.5pt][/size][/font][size=10.5pt][/size]
[size=10.5pt][url=http://www.51testing.com/batch.download.php?aid=9353][img]http://www.51testing.com/attachments/2008/04/138777_200804021554371.jpg[/img][/url] [/size]
[size=10.5pt][/size]
[size=3][size=5]2[font=宋体].添加用户[/font][/size][/size]
[font=宋体][size=10.5pt][size=2]方法:选择测试计划,用右键点击选择添加--> 线程组。[/size][/size][/font]
[font=宋体][size=10.5pt][/size][/font]
[font=宋体][size=10.5pt][color=black][size=10.5pt][url=http://www.51testing.com/batch.download.php?aid=9351][img]http://www.51testing.com/attachments/2008/04/138777_200804021551199.jpg[/img][/url] [/size][/color][/size][/font]
[font=Wingdings][size=10.5pt]n [/size][/font][font=宋体][size=10.5pt]线程数:即用户数[/size][/font][size=10.5pt] [/size]
[font=Wingdings][size=10.5pt]n [/size][/font][size=10.5pt]the Ramp-Up Period[/size][font=宋体][size=10.5pt]:这个属性表示每个用户启动的迟延时间,上图为每[/size][/font][size=10.5pt]2[/size][font=宋体][size=10.5pt]秒[/size][/font][size=10.5pt]1[/size][font=宋体][size=10.5pt]个用户([/size][/font][size=10.5pt]4[/size][font=宋体][size=10.5pt]个用户[/size][/font][size=10.5pt]/8[/size][font=宋体][size=10.5pt]秒)[/size][/font][size=10.5pt][/size]
[font=Wingdings][size=10.5pt]n [/size][/font][font=宋体][size=10.5pt]循环次数:这个属性表示你的测试重复次数[/size][/font][size=10.5pt][/size]
[size=3][size=5]3[font=宋体].设置默认[/font]HTTP[font=宋体]请求页(可选)[/font][/size][/size]
[size=3][size=5][font=宋体][/font][/size][/size]
[font=宋体][size=10.5pt][size=2][url=http://www.51testing.com/batch.download.php?aid=9344][img]http://www.51testing.com/attachments/2008/04/138777_200804021551192.jpg[/img][/url][/size][/size][/font]
[font=宋体][size=10.5pt][size=2]方法:选择线程组,右击选择添加 -->配置元件 --> HTTP请求默认值[/size][/size][/font]
[size=10.5pt][/size]
[size=3][size=5]4. [font=宋体]添加[/font] Cookie [font=宋体]支持[/font][/size][/size]
[size=10.5pt] [/size][font=宋体][size=10.5pt]方法:[/size][/font][font=宋体][size=10.5pt][size=2]选择线程组,右击选择添加 -->配置元件 --> HTTP Cookie管理器[/size][/size][/font]
[font=宋体][size=10.5pt][url=http://www.51testing.com/batch.download.php?aid=9343][img]http://www.51testing.com/attachments/2008/04/138777_200804021551191.jpg[/img][/url][/size][/font]
[font=宋体][size=10.5pt][size=2][/size][/size][/font]
[size=10.5pt][/size]
[size=3][size=5]5[font=宋体]、添加[/font] HTTP [font=宋体]请求[/font] ([font=宋体]此操作主要是链接首页测试[/font])[/size][/size]
[size=10.5pt] [/size][font=宋体][size=10.5pt]方法:[/size][/font][font=宋体][size=10.5pt][size=2]选择线程组,右击选择添加 --> Sampler --> HTTP 请求[/size][/size][/font]
[font=宋体][size=10.5pt][url=http://www.51testing.com/batch.download.php?aid=9345][img]http://www.51testing.com/attachments/2008/04/138777_200804021551193.jpg[/img][/url][/size][/font]
[font=宋体][size=10.5pt][size=2][/size][/size][/font]
[size=10.5pt][/size]
[size=3][size=5]6[font=宋体]、再添加一个[/font]HTTP[font=宋体]请求[/font] [font=宋体](此操作主要是[/font]admin[font=宋体]用户登录)[/font][/size][/size]
[size=10.5pt] [/size][font=宋体][size=10.5pt]方法:[/size][/font][size=2][font=宋体][size=10.5pt]选择线程组,右击选择添加 --> Sampler --> HTTP 请求[/size][/font][size=10.5pt][/size][/size]
[size=10.5pt][/size]
[font=宋体][size=10.5pt][/size][/font]
[font=宋体][size=10.5pt][url=http://www.51testing.com/batch.download.php?aid=9348][img]http://www.51testing.com/attachments/2008/04/138777_200804021551196.jpg[/img][/url][/size][/font]
[font=宋体][size=10.5pt]本人“同请求一起发送参数”设置是:[/size][/font][size=10.5pt][/size]
[table][tr][td=1,1,284][font=宋体][size=10.5pt]名称[/size][/font][size=10.5pt][/size]
[/td][td=1,1,284][font=宋体][size=10.5pt]值[/size][/font][size=10.5pt][/size]
[/td][/tr][tr][td=1,1,284][size=10.5pt]Comf[/size]
[/td][td=1,1,284][size=10.5pt]new_index[/size]
[/td][/tr][tr][td=1,1,284][size=10.5pt]loginform:username[/size]
[/td][td=1,1,284][size=10.5pt]admin[/size]
[/td][/tr][tr][td=1,1,284][size=10.5pt]loginform:password[/size]
[/td][td=1,1,284][size=10.5pt]1[/size]
[/td][/tr][tr][td=1,1,284][size=10.5pt]loginform[/size]
[/td][td=1,1,284][size=10.5pt]loginform[/size]
[/td][/tr][tr][td=1,1,284][size=10.5pt]loginform:_id0.x[/size]
[/td][td=1,1,284][size=10.5pt]15[/size]
[/td][/tr][tr][td=1,1,284][size=10.5pt]loginform:_id0.y[/size]
[/td][td=1,1,284][size=10.5pt]8[/size]
[/td][/tr][/table]
[size=3][size=5]7[font=宋体]、添加监听器[/font][/size][/size]
[size=10.5pt] [/size][font=宋体][size=10.5pt]方法:[/size][/font][font=宋体][size=10.5pt][size=2]选择线程组,右击选择添加--> 监听器 -- …… (你可以选择不同的方法监听操作)[/size][/size][/font]
[font=宋体][size=10.5pt][size=2]这里我们选择的是“用表格察看结果”和“察看结果树”[/size][/size][/font]
[font=宋体][size=10.5pt][url=http://www.51testing.com/batch.download.php?aid=9352][img]http://www.51testing.com/attachments/2008/04/138777_2008040215511910.jpg[/img][/url][/size][/font]
[font=宋体][size=10.5pt][url=http://www.51testing.com/batch.download.php?aid=9349][img]http://www.51testing.com/attachments/2008/04/138777_200804021551197.jpg[/img][/url][/size][/font]
[size=5]8[font=宋体]、保存测试计划[/font][/size]
[size=10.5pt] [/size][font=宋体][size=10.5pt]方法:文件[/size][/font][font=Wingdings][size=10.5pt][font=Wingdings]à[/font][/size][/font][font=宋体][size=10.5pt]保存测试计划[/size][/font][size=10.5pt] [/size][font=宋体][size=10.5pt]([/size][/font][size=10.5pt]Ctrl + S [/size][font=宋体][size=10.5pt])[/size][/font][size=10.5pt][/size]
[size=3][size=5]9[font=宋体]、运行测试计划[/font][/size][/size]
[size=10.5pt] [/size][font=宋体][size=10.5pt]方法:运行[/size][/font][font=Wingdings][size=10.5pt][font=Wingdings]à[/font][/size][/font][font=宋体][size=10.5pt]启动[/size][/font][size=10.5pt] (Ctrl + R)[/size]
[size=10.5pt] [/size]
[size=3][font=宋体][size=5]结果图:[/size][/font][/size]
[font=宋体][size=10.5pt][size=2]“用表格察看结果”显示的为:[/size][/size][/font]
[font=宋体][size=10.5pt][url=http://www.51testing.com/batch.download.php?aid=9346][img]http://www.51testing.com/attachments/2008/04/138777_200804021551194.jpg[/img][/url][/size][/font]
[font=宋体][size=10.5pt][size=2][/size][/size][/font]
[size=10.5pt][/size]
[font=宋体][size=10.5pt][size=2]“察看结果树”显示的为:[/size][/size][/font]
[font=宋体][size=10.5pt][url=http://www.51testing.com/batch.download.php?aid=9350][img]http://www.51testing.com/attachments/2008/04/138777_200804021551198.jpg[/img][/url][/size][/font]
[b]附件:[/b]
wuyefeng 2008-4-17 11:16
更正
配置jdk环境变量时错误,%JAVA_HOME\lib应该为%JAVA_HOME%\lib,少了个%
wangjinxiang 2008-4-28 16:38
您好!能给我发个下载JMeter的地址吗?为什么我总是下载不了?
camily 2008-4-29 09:20
回复 3# 的帖子
下载地址是:
[url]http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi[/url]