当前位置:网站首页>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 ~
边栏推荐
- 股市小白通过网上进行股票开户安全吗?
- What is a subnet mask? (Powercert animated videos)
- Is it safe to open an account with qiniu securities?
- Node connection MySQL
- Openocd adds third-party device support: ht32f52352 Cortex-M0+
- Local variables and global variables in C language
- Differences between modems and routers (powercert animated videos)
- How to solve the problem of flash write protection in STM32?
- Beginner to embedded development
- JS__ This, arguments, cloning, ternary operator__ Duyi
猜你喜欢
Command 'GCC' failed with exit status 1 when PIP install mysqlclient
Decryption of APP parameters of a cross-border export e-commerce - dunhuang.com
Docker failed to remotely access 3306 after installing MySQL
MySQL is slow to add indexes_ Why is your SQL so slow? Why is your MySQL index invalid?
[deep learning series] - visual interpretation of neural network
Boomfilter learning
js(3)
Yunzhisheng atlas supercomputing platform: computing acceleration practice based on fluid + alluxio (Part 2)
Sqlmap for interface security testing
Finger collar pin exclusive Medal
随机推荐
04 disk space management
[machine learning] machine learning from zero to mastery -- teaching you how to use decision tree to predict contact lens types
Getting started and using postman
[important notice] developer document update (12.13-12.19)
Docker Alpine image installation PHP extension redis
Nmap is simple and practical
Node installation method you don't know
Renren mall locates the file according to the route
js(3)
[summary] 2021unctf Campus (cry & MISC)
Send a more awesome website, which can convert curl commands into code in any language
Cvpr2021 collection of papers | cvpr2021 latest papers | cvpr2021 review results | cvpr2021 admission results
Idea implements hot deployment
Code program related problems troubleshooting directory
Rounding related calculation
[buucry] sensor (Manchester code)
2022年启牛学堂证券开户安全嘛?
Mutual conversion of CString and char*
01 network basics
[nailing scenario capability package] exhibition admission