当前位置:网站首页>JMeter basic learning records

JMeter basic learning records

2022-06-24 21:06:00 gchh_ spring

1、HTTP Request defaults

effect :

1、 Request default value can set the default value of request parameters 、 request url The default value of , If there are more than one http The body of the request is consistent , Then it can be set to the default value , Prevent a large number of changes after changes http request , Can play a good reuse effect

2、 If in a single http The request adds the same parameter as the default value , Is a single http The requested parameters prevail , At this time, the default value is set to this http Invalid , The default value takes effect only when no parameters are filled in

How to add :

 

2、HTTP Header Manager

effect :

You can customize the value of the header field through the header manager , For example, modify User-Agent Change the value of to another value ( The screenshot has not been changed ,Value Values can be entered by yourself )

How to add :

3、 User defined variables

effect :

It's going on http When asked , If the value of a parameter requires multiple tests , Then you can customize the variables , At the same time http Call the user-defined variable in the request parameter , Call mode :${ Variable name }, such as ${date1}

How to add :

4、 Request element -- A parameterized txt

effect :

User defined variables can be written to txt In file , By adding CSV Date Set Config Components , take txt Document import , Define variable name , Loop through the test txt Multiple lines of data in the document , This can reduce http Number of requests created

such as , There is a login interface , You will design normal login 、 Wrong user name 、 Wrong password 、 User name is empty 、 The password is empty. 、 All are empty use cases , So you can create a txt file , Write your test data in the following format

stay http Request in sampler , Get by calling variables txt Value information of , If you need to traverse txt All values in it , You can set the number of cycles to 6( Because our data is 6 strip , Set... According to the actual situation ), Then you can loop through txt The data in it

How to add :

5、 Request element -- A parameterized csv

effect :

A parameterized csv Same as txt It's the same operation , Only the imported file becomes csv file ( You can create excel Save as after csv file ),csv Is text in tabular format , For data creation and data viewing txt It is better to

6、 Parameterized function assistant _CSVRead

effect :

By using jmeter Internal function _CSVRead Read csv File content to parameterize http Request data , Practical and parametric csv similar , It's just a function call , Finally, the variable name generated by the calling function is called

In the function dialog box in the figure below , If you want to get information about the second column and the number of subsequent columns , Then fill in the column information separately 1,2,... equivalence

By function _CSVRead Get the parameter value information , If you want to traverse all the parameters set in the file , Then set the value of the number of threads in the thread group to the actual number of parameter lines , Instead of setting the number of cycles

How to use :

Open function assistant :

Function Assistant dialog :

How to call the variables generated by the function assistant :

7、 Parameterized function assistant _randomstring

effect :

Call this function to automatically generate random data , To some extent, you don't have to prepare the test data yourself , But this method can not guarantee the uniqueness of the data , Because the randomly generated data may be duplicated

Use the same way as csvread Function similar to , The following figure shows how to use and generate

How to use :

8、 The regular expression extractor gets the response result

effect :

You can extract the content you want from the specified response data : Both header and response data can be extracted

Regular expression extractors must be added under a request , As its sub request , Otherwise, the specified data cannot be extracted

How to use :

1、 In extractor ( such as http request ) Now create a regular expression extractor , Then fill in the information of the extractor

2、 How to view the extraction results of regular expressions :

First, add... Under the thread group Debug Sampler, After operation , View the extracted information under the view result tree

Be careful : If one sampler needs to use the regular extractor values of other samplers , Then this sampler should be placed in front of the sampler that references it , The variables and variable values in the regular extractor can be obtained normally

Normal after position change

9、 The regular expression extractor gets an array

effect :

Last summary ( The first 8) It only shows how to get one or more data from one data , So this is to obtain data information from multiple data

How to use :

10、 Logic controller -foreach controller

effect :

You can traverse the values of some similar variables

How to use :

11、json path The extractor gets the response result

effect :

The returned data is json When formatting data , have access to json Extractor to get the information in the response data

How to use :

jsonpath grammar :$ Represents the root path

12、jmeter Of cookie Processing mode - add to http cookie Manager

effect :

add to cookie Information , It can guarantee the success of subsequent request operations

How to use :

Add... In addition cookie You can also use the regular expression extractor to get cookie Information , And will cookie The information is placed in the next request header , It is possible to manually cookie Information added to cookie Manager

 

 

 

 

 

原网站

版权声明
本文为[gchh_ spring]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202211321067809.html