当前位置:网站首页>JMeter learning notes
JMeter learning notes
2022-06-30 12:52:00 【The hunter is eating meat】
List of articles
- 1、CSV Data Set Config
- 2、 Regular expression extractor
- 2.1、 Regular expressions —— There is only one matching value
- 2.2、 Regular expressions —— There are multiple matching values
- 2.3、 Regular expressions —— There are multiple row and column matching values
- 2.4、 Example ,jmeter Use the regular expression extractor to get the value and Set global variables
- 3、 Two methods of data extraction
- 4、 Function assistant
1、CSV Data Set Config
D Plate ,data.txt The content of :
CSV Data Set Config
The configuration is as follows :
Description of each parameter :
Filename( file name ) : Support relative and absolute paths . Relative path refers to the path saved by the script as the current relative path
Variable Name( Variable name ) : We can set as many variables as there are columns of data , Separated by commas .
If this item is empty ,jemter Will go to parse csv Of documents header, in other words , If your csv The document has a header , Then you can not set the variable name ,jmeter The name of the header will be automatically resolved to a variable .Allow quoted data : If your csv The contents of the file contain separators , The default separator is comma , Then check this item , Just enclose the value in double quotation marks
Sharing mode : This is more difficult to understand , We can simply think of this option as configuration jmeter How to open csv Of documents . It has 4 An option :
Option parameters meaning All threads All virtual users use the same csv file Current thread group One per thread group csv file Current thread Every thread ( Virtual user ) Use one csv file Identifier Customize
2、 Regular expression extractor
Usage scenario of regular expression extractor :
Get the data returned from dynamic changes in the application to , Save it as a parameter , It is provided for use in the future .
such as , The parameters of the next interface need to refer to the values in the returned data of a previous interface , Can pass Regular expression extractor To get the value .
The meaning of each parameter value :
Parameters | paraphrase |
---|---|
Quote name | stay HTTP Waiting for request , Reference this data , The name you need |
Regular expressions | Used to extract the required data |
Templates | Represents the number of values extracted :$1$: Take the first place 1 individual ( Column ) $2$: Take the first place 2 individual ( Column ) And so on :$n$: Take the first place n individual |
Match the Numbers (0 For random ) | 0 Represents a random value ,1 Represents all values |
The default value | If the regular expression does not find a value , This default value is used |
2.1、 Regular expressions —— There is only one matching value
(1) Regular expression testing
The text is as follows , It is known that 9 This number .
javawind:9
The regular expression used in the test is as follows :
Regular expression Tester Instructions :
The first 1 Column is the original content of the matching file , Not a match .
From 2 The column starts with the matching extraction result .
The regular expression is javawind:(.*)
, It can be seen from the test results that , The first 2 Column ( That is, the index is 1 ) That is The result of extraction .
(2) Regular expression extractor configuration
Because there's only one value ( Index from 1 Start calculating ), Value using $1$
, As shown in the figure below :
(3) Reference in other components
When using variables , Just quote the name .
2.2、 Regular expressions —— There are multiple matching values
(1) Regular expression testing
As shown in the figure below , In a row , There are two matching values .
(2) Regular expression extractor configuration
In the last step , There are two matching values in a row , If you want to take the number 1 It's worth , Then use $1$
, If you want to take the number 2 It's worth , Then use $2$
, And so on .
(3) Reference in other components
When using variables , Just quote the name .
2.3、 Regular expressions —— There are multiple row and column matching values
There are multiple rows and columns of matching data , Is not common .
(1) Regular expression testing
As shown in the figure below , Yes 3 That's ok 2 Column matching data .
(2) Regular expression extractor configuration
analysis , If you want to get The first 2 Column 、 The first 2 It's worth it , Corresponding J yes ($2$, ${javawd_g2})
, If it's No 3 Column 、 The first 4 It's worth it , It corresponds to ($3$,${javawd_g4})
.
below , We take The first 2 Column , The first 2 That's ok , The value is 17
As an example of .
First , Regular expression extractor template filling $2$
, Said to get The first 2 Columns of data .
(3) Reference in other components
In the last step The first 2 Column On the basis of , If you want to take The first 1 That's ok The data of 16
, Then fill in ${javawd_g1}
,
If you want to take The first 2 That's ok The data of 17
, Then fill in ${javawd_g2}
.
2.4、 Example ,jmeter Use the regular expression extractor to get the value and Set global variables
In the interface test , Many interfaces log in first and then , obtain token , take token Set to global variable , Then you can call other interfaces .
There will be one in the information returned after login token value , Use regular expressions to extract token Value ,
then , Use In the post processor Of BeanShell PostProcessor
Set up token Is a global variable .
(1) see token value :
see token There are many ways , Common methods are as follows .
- use fiddler Grab the bag
- F12 View interface information
- use jmeter Log in to view
(2) Regular expression extraction token
(3)BeanShell PostProcessor Set up token Is a global variable .
(4) Other interfaces use this global variable :
add to http Header Manager
3、 Two methods of data extraction
Get the data returned in the previous step to , Save it as a parameter , For the following steps .
As shown in the figure below , Password login interface After successful execution , Return some data . In this data token
、userId
Must be used in subsequent interface calls .
extract Password login interface Returns... In the value token
、userId
There are two ways , The first 1 One is the regular expression extractor , The first 2 Species is JSON Extractor .
3.1、 Method 1, Regular expression extractor
extract Password login interface Returns... In the value token
、userId
, As shown in the figure below .
debug sampler
You can see userId、token Extracted ; The quotation is written as :${token}
, ${userId}
.
3.2、 Method 2,JSON Extractor
extract Password login interface Returns... In the value token
、userId
, As shown in the figure below .
debug sampler
You can see userId、token Extracted ; The quotation is written as :${token}
,${userId}
.
3.3、 Value reference ${ }
There are two ways to extract parameters , The next step is to reference the extracted value in the next interface parameter .
As shown in the figure below , stay http I quote token value ,
Click the execute button , stay http Fruit trees in see Request data , You can see token
Citation .
Execution results , As shown in the figure below , stay http Of Fruit trees View in The response data , The interface was also executed successfully .
4、 Function assistant
(1) open Function Assistant dialog
(2) choice __CSVRead
Function function .
(3) Prepare the data , As shown in the figure below .
stay D Disk creation data.txt file , The contents are as follows :
(4) To configure __CSVRead
The parameter value of the function
Option parameters | meaning |
---|---|
CSV file to get values from | To read the full path of the file |
CSV File column number | Which column of data to read . The default is 0 At the beginning ,0 Express The first 1 Column . 0 It means the first one 1 Column 1 It means the first one 2 Column And so on |
After the above values are filled in , Click on Generate Button , Generate Quoted variables .
(4) reference parameter
username It's No 1 Column , Fill in ${__CSVRead(D:\data.txt,0)}
pwd It's No 2 Column , Fill in ${__CSVRead(D:\data.txt,1)}
(5) verification
A little
边栏推荐
- 第十三章 信号(三)- 示例演示
- Efficient elliptic curve point addition and multiplication in scrypt
- IDEA 2021.3 执行 golang 报错:RNING: undefined behavior version of Delve is too old for Go version 1.18
- 你想要的异常知识点都在这里了
- STM32 移植 RT-Thread 标准版的 FinSH 组件
- SQLSERVER 查询编码是 936 简体中文GBK,那我是写936 还是写GBK?
- Tronapi-波场接口-源码无加密-可二开--附接口文档-基于ThinkPHP5封装-作者详细指导-2022年6月29日21:59:34
- RDS MySQL数据迁移PolarDB MySQL费用可以转过去吗?
- How to select an OLAP database engine?
- Event handling in QT
猜你喜欢
[learn awk in one day] operator
FlinkSQL自定义UDTF使用的四种方式
江西财经大学智慧江财登录分析
Redis - problèmes de cache
After the market value evaporated by 65billion yuan, the "mask king" made steady medical treatment and focused on condoms
【驚了】迅雷下載速度竟然比不上虛擬機中的下載速度
Unity脚本的基础语法(1)-游戏对象的常用操作
uniapp支付之APP微信支付unicloud版(附源码)
How to select an OLAP database engine?
Questionnaire star questionnaire packet capturing analysis
随机推荐
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matchin问题
Terms related to JMeter performance test and performance test passing standards
【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(二)
LeetCode_栈_中等_227.基本计算器 II(不含括号)
Unity脚本的基础语法(5)-向量
Flink sql控制台,不识别group_concat函数吗?
Apple executives openly "open the connection": Samsung copied the iPhone and only added a large screen
rpm2rpm 打包步骤
江西财经大学智慧江财登录分析
2022-06-23 帆软部分公式及sql生成(月份、季度取数)
写信宝小程序开源
基于ThinkPHP5封装tronapi-波场接口-PHP版本--附接口文档-20220627
The spiral matrix of the force buckle rotates together (you can understand it)
Definition of variables and assignment of variables in MySQL
FlinkSQL自定义UDTF使用的四种方式
【精选】资源变现资讯、新闻、自媒体、博客小程序(可引流,开通流量主,带pc后台管理)
电机控制park变换公式推导
资源变现小程序开通流量主教程
[yitianxue awk] regular matching
uniapp支付之APP微信支付unicloud版(附源码)