当前位置:网站首页>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-波场接口-源码无加密-可二开--附接口文档-基于ThinkPHP5封装-作者详细指导-2022年6月29日21:59:34
- ffmpeg 杂项
- 你想要的异常知识点都在这里了
- Package based on thinkphp5 -tronapi- wave field interface - source code without encryption - can be opened twice - interface document attached - detailed guidance of the author - June 30, 2022 08:45:2
- Introduction to the new source code of substrat: fix the memory leak of the mission engine of beefy, and optimize the smart contract deletion queue
- Sqlserver query code is 936 simplified Chinese GBK. Should I write 936 or GBK?
- Dark horse notes - collection (common methods and traversal methods of collection)
- Android development interview real question advanced version (with answer analysis)
- 【一天学awk】基础中的基础
猜你喜欢

电机控制Clarke(α/β)等幅值变换推导

独立站即web3.0,国家“十四五“规划要求企业建数字化网站!
![[MySQL] MySQL installation and configuration](/img/82/8500949734e57e6a1047c4e838f625.png)
[MySQL] MySQL installation and configuration

Redis cache problem

Visual studio configures QT and implements project packaging through NSIS

Google refutes rumors and gives up tensorflow. It's still alive!

Sarsa notes

Q-learning notes

Today in history: Microsoft acquires PowerPoint developers; SGI and MIPS merge

Four ways for flinksql to customize udtf
随机推荐
Introduction to the renewal of substrate source code: the pledge amount is greatly reduced, and rocksdb can be completely disabled
MySQL judges the calculation result and divides it by 100
How to solve cross domain problems
Tencent two sides: @bean and @component are used on the same class. What happens?
问卷星问卷抓包分析
Event handling in QT
微信小程序报错:TypeError: Cannot read property ‘setData‘ of undefined
postman 自动生成 curl 代码片段
mqtt-ros模拟发布一个自定义消息类型
Discussion on JMeter operation principle
MATLAB小技巧(22)矩阵分析--逐步回归
Android development interview real question advanced version (with answer analysis)
QT read / write excel--qxlsx worksheet display / hide status setting 4
Vision based robot grasping: from object localization, object pose estimation to parallel gripper grasping estimation
Package based on thinkphp5 -tronapi- wave field interface - source code without encryption - can be opened twice - interface document attached - detailed guidance of the author - June 30, 2022 08:45:2
【一天学awk】基础中的基础
【 surprise】 la vitesse de téléchargement de Thunderbolt n'est pas aussi rapide que celle de la machine virtuelle
Three ways for flinksql to customize udaf
Unity脚本的基础语法(5)-向量
ECDSA signature verification in crypt