当前位置:网站首页>Jmeter- (II) basic interface and common components for interface testing
Jmeter- (II) basic interface and common components for interface testing
2022-06-25 21:18:00 【Hello, test】
Preface :
This is mainly about Jmeter test http Interface , Common components involved , Include :
( One ) Basic interface and component concepts
( Two ) Common configuration components
( 3、 ... and )HTTP Request standard components
( One ) Basic interface and component concepts
1. test plan : It's using jmeter The starting point for testing , It's something else jmeter Containers for test elements
2. Thread group : Represents a certain number of concurrent users , It can be used to simulate the sending request of concurrent users . The actual request content is in the thread group -> Defined in the sampler , It is contained by the thread group , This can be done in the test plan --> add to --> Thread group to create


Parameter interpretation :
Number of threads : Maximum number of threads used in the test , The default is 1, It can be used to set the number of concurrent users .
Ramp-Up Period : Jmeter Time to reach the specified maximum number of threads .
① 0 Concurrent on behalf of ;
② If the number of threads is 3, The required duration is 3S, be 3/3=1 every other 1S Start a thread ;
③ General Settings Ramp-Up= Number of threads , Then adjust it up and down to the desired .
cycles : If it is Forever, The threads in the thread group will continuously test the system , Of course, you can also set the number of tests per thread , When the specified number of times has been completed , The thread will automatically exit the thread group .
Scheduler : It is mainly used to specify some time information of the test , For example, from what time to what time to run the test , If the test is not completed at the specified time , The test will also be stopped ( This is rarely used )
( Two ) Common configuration components
test http Interface request , You need to add a definition first header Related components :
1. HTTP Header Manager :
HTTP The header manager allows you to customize JMeter stay HTTP What message does the request message send . The message header includes something like "User-Agent", "Pragma", "Referer" Equal attribute .
HTTP The header manager is like HTTP Cookie The manager is the same , If you don't want to be different in your test for some reason HTTP The request object specifies a different header , Can be added to the thread group level .
Select Add --> The configuration element -->HTTP Header Manager

Parameter interpretation :
name / notes : You can customize .
Message header : You can add interface parameters by yourself , Set the corresponding name and value .
It needs to be said here , If R & D does not provide relevant header information , We can also open the console ourselves ,F12( Developer model ) Go down and get it !!

2. HTTP Cookie Manager :
Unless your application explicitly does not use Cookies, Almost all web applications use cookie Support . You want to add cookie Support , You can simply add one to each thread group in your test plan HTTP Cookie Manager . This ensures that each thread group has its own cookies.
add to HTTP Cookie Manager , Simply choose this Thread group , Select Add --> The configuration element -->HTTP Cookie Manager , You can also add from the edit menu or by right clicking . 
It needs to be said here , If R & D does not provide relevant header information , We can also open the console ourselves ,F12( Developer model ) Go down and get it !!

3. User defined variables : Select sampler , Right click : add to - The configuration element - User defined variables
It usually parameterizes the values common to the whole thread , It is easy to maintain later , If there are changes, you do not need to modify each interface one by one .

( 3、 ... and )Http Request standard components
We have already introduced the basic components , Next, we can add interface requests under the thread .
1. HTTP request : Thread group -> Sampler ->http Request add


explain : Some interfaces have no message body , You need to directly transfer parameters on the interface path , In this case, we can directly add interface parameters .

2. Response assertion : Mainly used to judge http Whether the request is called successfully , This and http The request is standard . Add a path :http request -> Assertion -> Response assertion add


Parameter interpretation :
Test fields : Select the location where you want to judge the content , For example, the response header information is used to determine whether it is successful , This can be selected according to your own needs .
Matching specifications : The literal meaning is easy to read , Choose exact match or include, and so on ...
Test mode : This is the real judgment condition , Be consistent with the response information of the interface , If there is no match, the interface call fails .
3. The regular expression extractor gets : The main user obtains the parameters returned by the interface , Next to get token For example
Add location : Post Processors - Regular expression extractor


name + notes : It is not necessary to modify , Just for the convenience of self identification
Fields to check : Main body, etc , Generally, we choose the subject , That is, the main body information of the page returned by the server
【 Quote name 】: Is the parameter name , Quote elsewhere ; Such as the input TOKEN, Use when quoting elsewhere ${TOKEN}
【 Regular expressions 】: Expression () The contents in the are to be extracted . Such as "token": "(.+)", "userUpdate", Expression lookup token/ What follows the string , Until the first user End of time ;( Note the extracted content in parentheses )
(): The enclosed part is to be extracted .
.: Match any string .
+: Once or more .
?: Stop after first match found .
【 Templates 】: use $$ To quote , If there are multiple regular expressions in a regular expression ( What's in brackets ), It can be $1$( Indicates that there is only one set of data ),$2$ wait , Represents resolved to 1 individual 、 The first 2 Give a value to mysid
【 Match the Numbers 】:0 Represents a random value ,-1 On behalf of all ,1 Represents all values
【 The default value 】: If the parameter does not get a value , Then use the default value here
4. Commissioning the samplers : The main user prints the parameter values obtained , Convenient for debugging
Add location : Thread group -> Sampler -> Commissioning the samplers

5. Look at the fruit tree : Used to view the returned results of the interface , It can be used directly after adding without configuration .
Add location : Thread group -> Monitor -> View the result tree


Hello Test, So far we jmeter That's all for the basic components of , According to this document, we should be able to write a simple http Interface test script , Let's try it ~~ The following screenshot was written by me The user login -- Get login token-- A new user Script for , You can refer to the structure , In the next chapter, I will introduce how to write a simple script for creating a new user , Everyone pays attention in time , finger heart ~

边栏推荐
- 股市小白通过网上进行股票开户安全吗?
- Cvpr2020 | the latest cvpr2020 papers are the first to see, with all download links attached!
- 同花顺炒股软件开户是合法的吗?安全吗
- Basic knowledge of software engineering required for soft test
- Unable to connect to the server remotely locally using the Jupiter notebook
- Mutual conversion of CString and char*
- Alicloud disk mounted locally
- C language: array with length 0
- Xshell mouse configuration
- Lesson 3 urllib
猜你喜欢

Install JDK, MySQL and nexus under Linux (tar package installation)
Uncover n core 'black magic' of Presto + alluxio

Big end and small end
![[important notice] developer document update (12.13-12.19)](/img/49/6a54235409ec95fa50bcc14ef1d405.jpg)
[important notice] developer document update (12.13-12.19)

Decryption of APP parameters of a cross-border export e-commerce - dunhuang.com
![[nailing scenario capability package] enterprise and public institution intelligent access control](/img/0e/43433ca5586c48d01708e5fa39a808.jpg)
[nailing scenario capability package] enterprise and public institution intelligent access control

What is DNS (domain name server)? (Powercert animated videos)

How to solve the problem of flash write protection in STM32?

Sqlmap for interface security testing

Getting started and using postman
随机推荐
Docker failed to remotely access 3306 after installing MySQL
js (1)
Beginner to embedded development
Get parameters in URL
The correct way to clear the cache of the computer. The computer will not get stuck immediately after changing. practical
What is a server? (Powercert animated videos)
The difference between strcpy and memcpy
Renren mall locates the file according to the route
Patrol script
Introduction to interface test, interface protocol and common interface test tools
R language quantile autoregressive QAR analysis pain index: time series of unemployment rate and inflation rate
Getting started and using postman
Cvpr2019 | the latest cvpr2019 papers are the first to read!
The user name and password will be automatically filled in when adding a form
[buucry] sensor (Manchester code)
同花顺炒股软件开户是合法的吗?安全吗
Win10 common software
What is a subnet mask? (Powercert animated videos)
Vbpr (visual Bayesian personalized ranking) paper summary
Data query of server SQL. The most important chapter in database learning