当前位置:网站首页>Jmeter use
Jmeter use
2022-08-03 13:04:00 【Amen's Love】
一、背景
JmeterIt is currently very process testing software,JMeter是纯JAVA语言写的应用程序,It supports mainstream testing protocols,包括FTP/LDAP/JMS/HTTP(S)/JDBC等.
二、Common test interface classification
- Soap框架
基于webservice的协议:接口地址:http://…?wsdl - RPC框架
基于(dubbo(thwift))协议的接口:dubbo:// - RestFull框架(80%)
基于http协议:
请求:请求行(Request method and request route),请求头,请求报文
请求方式:get、post、put、delete
请求路径:url
请求头:
Accept:如application/json; 指定客户端接收的数据格式
Content-type:如application/json;Specifies the data format sent by the client
X-Requested-with:异步请求(登录,ajax)
User-Agent:如User-Agent: Mozilla/5.0 客户端的类型,Indicates the browser request or some other device request
Cookie:服务器返回给客户端并且保存的Cookie信息
响应:响应行(响应码和响应信息),响应头,响应报文
响应码:一般情况:1xx状态;200成功;3xx重定向;4xx客户端错误;5xx服务端错误
- backups 备份目录,jmx的脚本,Automatically save here.
- bin 存放jmeter的启动脚本,配置文件,模块文件
jmeter.bat 启动脚本
jmeter.properties 全局配置文件,如:永久中文 修改language=ZH_CN - extras Deposit and third-party build files,比如:Ant,build.xml
四、Components and execution order and scope
4.1 组件
- 测试计划:jmeter的起点和容器
- 线程组:代表一定的虚拟用户
- *取样器:发送请求的最小单元
- 逻辑控制器:控制组件的执行顺序
- 前置处理器:Executed before the request
- 后置处理器:在请求之后执行
- 断言:判断请求是否成功
- 定时器:是否延迟或间隔发送请求
- 配置原件:请求期的配置信息
10.监听器:Responsible for collecting test results
4.2 执行顺序
执行计划→ 线程组→配置原件→前置处理器→定时器→取样器→后置处理器→断言→监听器
4.3 组件作用域
Basically the scope of each component fits the following rules:A component acts on its parent and siblings, as well as children of siblings.
4.4 接口测试流程
一般一个接口:20到30This use case is relatively normal.
五、The first test instance
A standard use case generally includes the following
5.1 添加测试计划

5.2 在测试计划下添加线程组

5.3 在线程组下添加【配置元件】
5.3.1 添加 cookie管理器

5.3.2 添加【用户自定义的变量】

引用变量:${xxx}
5.3.3 添加【HTTP请求默认值】
Usually add requestsip和端口,In this way, there is no need to write again in the samplerip和端口了.

5.4 *在线程组下添加【取样器】
5.4.1 【HTTP请求】取样器


*5.4.2 【BeanShell取样器】
5.5 在线程组下添加【监听器】用于查看结果,以【查看结果树】为例



5.5.1 Commonly used filtering methods【正则表示式】

5.5.2 Commonly used filtering methods【json表示式】


5.6 Add Extractor under Sampler,最常用的是【正则表达式提取器】和【JSON提取器】
Extractors are available at 5.5to test for correctness
5.6.1 正则表达式提取器


* The all-in-one regular expression extractor

"label":"(.*?)",[\s\S]*?"sValue":"(.*?)"
5.6.2 JSON提取器


5.6.3 添加调试取样器,Used to view sampler results


5.7 添加调试取样器
Via debug sampler,You can better view the contents of the sampler

5.8 ForEach控制器,Use it to implement bulk deletes.



5.9 定时器


5.10 文件上传接口

5.11 接口断言【响应断言】,【JSON断言】,【BeanShell断言】

5.11.1 响应断言-状态断言

5.11.2 响应断言-业务断言

5.11.3 断言成功

5.12 数据驱动,Bulk custom parameters,Some interfaces can be used when counterexample testing is required,批量操作.
新建一个.csv 文件 Write the parameters in




5.13 数据库驱动
5.13.1 在jemeter下添加mysql连接驱动

5.13.2 JDBC连接池配置


5.13.3 JDBC Request jdbc请求


5.13.4 返回结果处理

六、通过jemeterRecording interface documentation passedjmeter的http代理服务实现.
6.1 添加一个【HTTP代理服务器】

6.2 Proxy service settings
6.2.1 添加代理服务器

在这里插入图片描述



6.2.3 启动

七、The generation and use of variables
7.1 *变量的使用
1.jsonor a regex extractor variable:${变量名} (This method can only access within the thread)去访问,可以 用在httprequest address bar,Request body and other methods
2.beanshell中的变量:
//添加全局变量
props.put("_all_name","张三");
props.put("_all_age",23+"");
// Add variables within the thread
vars.put("_name","李四");
vars.put("_age",8+"");
// 获取全局
log.info(props.get("_all_name"));
log.info(props.get("_all_age"));
Or get global variables through a function
log.info("线程2---"+props.get("_all_name")+":"+props.get("_all_age"));
log.info("线程22---${__property(_all_name,,)}"+":${__property(_all_age,,)}");
// Get inside the thread
log.info(vars.get("_name"));
log.info(vars.get("_age"));
八、函数的使用
## 1-100的随机数
${__Random(1,100,aaa)}
## 从abcdefg随机找出2个字母
${__RandomString(2,abcdefg,)}
## 设置全局变量password=111111
${__setProperty(passwrd,111111,000000)}
## 获取全局变量的值
${__P(passwrd,)} 或 ${__property(passwrd,,)}x
## 分割成数组,可以用${data_x} 访问
${__split(a;b;c;d,data,;)}
结果:
data_n=4
data_2=b
data_1=a
data_4=d
## 当前时间戳
${__time(,)}
九、最佳实战

边栏推荐
猜你喜欢

Notepad++ 安装jsonview插件

An工具介绍之宽度工具、变形工具与套索工具

业界新标杆!阿里开源自研高并发编程核心笔记(2022最新版)

An introduction to basic tools for selecting line tools (package church)

欧曼自动挡、银河大马力、行星新产品 欧曼全新产品以燎原之势赢领市场

An工具介绍之摄像头

Comics: how do you prove that sleep does not release the lock, and wait to release lock?

海外代购系统/代购网站怎么搭建——源码解析

基于php旅游网站管理系统获取(php毕业设计)

浅谈程序员的职业操守
随机推荐
Autumn recruitment work
From the physical level of the device to the circuit level
PolarFormer: Multi-camera 3D Object Detection with Polar Transformers 论文笔记
An工具介绍之宽度工具、变形工具与套索工具
In order to counteract the drop in sales and explore the low-end market, Weilai's new brand products are priced as low as 100,000?
Image fusion DDcGAN study notes
【精品必知】Pod生命周期
随机森林项目实战---气温预测
图像融合DDcGAN学习笔记
Comics: how do you prove that sleep does not release the lock, and wait to release lock?
An动画优化之传统引导层动画
Tinymce plugins [Tinymce扩展插件集合]
可重入锁详解(什么是可重入)
来广州找工作有一个多月了,今天终于有着落了,工资7000
无监督学习KMeans学习笔记和实例
An introduction to basic tools for selecting line tools (package church)
Classes and Objects (lower middle)
从器件物理级提升到电路级
【Verilog】HDLBits题解——Circuits/Sequential Logic/Latches and Flip-Flops
(通过页面)阿里云云效上传jar

