当前位置:网站首页>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
边栏推荐
- Tronapi- wavefield interface - source code without encryption - can be opened in two places - interface document attached - encapsulation based on thinkphp5 - detailed guidance of the author - 21:59:3
- 【惊了】迅雷下载速度竟然比不上虚拟机中的下载速度
- RDS MySQL数据迁移PolarDB MySQL费用可以转过去吗?
- 【一天学awk】数组的使用
- ECDSA signature verification in crypt
- Redis - problèmes de cache
- Understanding and mastery of ffmpeg avbufferpool
- Visual Studio配置Qt并通过NSIS实现项目打包
- [one day learning awk] array usage
- Spatiotemporal prediction 2-gcn_ LSTM
猜你喜欢

Database usage in QT

如何利用AI技术优化独立站客服系统?听听专家怎么说!

Analysis of smart jiangcai login in Jiangxi University of Finance and Economics

Tencent cloud Database Engineer competency certification was launched, and people from all walks of life talked about talent training problems

Reading the table data of Tencent documents in the applet
![[one day learning awk] array usage](/img/75/4333452142a3c7325e0712f3306985.png)
[one day learning awk] array usage

Qt读写Excel--QXlsx工作表显示/隐藏状态设置4

【OpenGL】OpenGL Examples

【MySQL】MySQL的安装与配置

Dark horse notes - collection (common methods and traversal methods of collection)
随机推荐
黑马笔记---常用日期API
Questionnaire star questionnaire packet capturing analysis
黑马笔记---List系列集合与泛型
Qt中的数据库使用
Problems and analysis in JMeter performance testing. How many problems have you encountered?
第十三章 信号(三)- 示例演示
【一天学awk】数组的使用
波卡跨链通信源码探秘: 要素篇
ffmpeg 杂项
SQLSERVER 查询编码是 936 简体中文GBK,那我是写936 还是写GBK?
Solve numpy core._ exceptions. Ufunctypeerror: UFUNC 'Add' did not contain a loop with signature matching
Visual studio configures QT and implements project packaging through NSIS
elementui中清除tinymce富文本缓存
Substrate 源码追新导读: Call调用索引化, 存储层事物化全面完成
【惊了】迅雷下载速度竟然比不上虚拟机中的下载速度
资源变现小程序开通流量主教程
时空预测2-GCN_LSTM
An interesting thing happened in the project
【OpenGL】OpenGL Examples
uniapp支付之APP微信支付unicloud版(附源码)