In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
I. the definition of parameterization
The so-called parameterization is the process of saving the data sent by the client to the server in advance to a parameter.
Generally speaking, for functional testing, when testing the same function with different data, we can use parameterization to simplify the test.
For performance testing, in order to truly simulate the operation behavior of multiple users or to deal with the system's special restrictions on multiple users operating at the same time (such as data uniqueness requirements), parameterization is needed to solve these problems.
JMeter provides a lot of ways and means of parameterization, including:
1. Configure component CSV_Data_Set_Config2. Built-in parameterized functions such as _ _ CSVRead ()
In this section, we mainly talk about CSV_Data_Set_Config parameterization.
Configuration item
Configure the CSV Data Source:
1.Filename:
The path or name of the data file to read. You can use an absolute path or a relative path.
When a relative path is used to represent a file path, the directory where the test plan is located is the current directory.
When JMeter runs in distributed mode, the parameterized data files need to be copied to each Slave and the same directory structure is set.
2.File Encoding:
If it is not set, the data file is read with the character encoding of the operating system. You can specify the encoding to read the data file to prevent garbled.
For example, if the default character encoding of the operating system is GBK, and the encoding of the data file (CSV file) is UTF-8, the read data must be garbled. In this case, you need to set File Encoding to "UTF-8" to read successfully.
3.Variable Names (comma-delimited):
A list of variable names used to hold the column values of the data file. Variable names are separated by, (comma). If the variable name list is empty, JMeter takes the field values of the first row of the data file as each variable name (regardless of whether the first row is ignored or not).
For example, there are two lines of values in the data file:
Zhang San, male, 25
Li Si, female, 20
If the list of variable names is not set, the three values in the first row are treated as variable names:
Zhang San, male, 25
The values of ${Zhang San}, ${male} and ${20} are: Li Si, female, 20
4.Ignore first line (only used if Variable Names is not empty):
Whether to ignore the first line of the data file. This option works only if the list of parameter names is set.
Select True to ignore the first line, and select False to ignore the first line. Generally, when there is a column header in a data file, it can be ignored because the title is not a value.
First line.
For example, the following values are found in the data file:
Name,sex,age
Zhang San, male, 25
Li Si, female, 20
If this item is set to False, name,sex,age will be read as the value of the variable, and set to True to ignore this row, starting with the second line.
5.Delimiter (use'\ t'for tab):
The delimiter of the field in the data file. Save the record split to the defined variable based on the delimiter. The default value is, (comma) separated.
6.Allow quoted data?:
Whether double quotation marks are allowed for values in the data file. True means allowed, False means not allowed.
Generally used when a value contains a delimiter, you can consider enclosing the value in double quotation marks to shield the special meaning of the delimiter.
For example, a data file that records the item number, name, and price:
Goods_id,goods_name,price
1Jing Watchmaker wanguo, "1500000"
If you do not use double quotation marks, the commodity price is 1, if you use double quotation marks, the commodity price is
1500000
7.Recycle on EOF?:
Read to the end of the data file (EOF, that is, end of file), whether to return to the file to start re-reading.
True loop read, False does not cycle read.
8.Stop thread on EOF?:
Read whether to stop the thread when it reaches the end of the data file. True stops the thread, the test is no longer going on
False does not stop the thread and continues to loop through the values to run the test.
9.Sharing mode:
Shared mode. All threads all threads, Current thread group current thread group, Current thread current thread.
1) All threads:
All threads share the same file. In the test, the data file is opened only once, and each thread reads the parameter values of different peers.
The value read by each thread is related to the order in which the thread starts; each thread assigns a parameter value regardless of whether the thread references a parameter or not.
2) Current thread group:
The current thread group. Each thread group under the test plan opens a separate parameter file.
3) Current thread:
The current thread. Each thread opens a separate parameter file. In this mode, if each thread needs to take values from a different value set
You can set up a set of parameterized data files, one for each thread. It will be fine to associate the thread number with the data file name.
For example, a set of files is:
Testdata1.csv,testdata2.csv,...
Testdatan.csv
The thread number can be obtained through the built-in function ${threadNum}, then the data file name can be set to: testdata$ {threadNum} .csv.
For example:
Take the previously introduced API for querying the total amount of goods purchased as an example:
Parameterization steps:
1. Determine which of the interface parameters need to be parameterized
When designing test cases, we prepare data for item number, commodity specification, and commodity quantity.
So the parameterization of id,attr,number
two。 Save the test data in an external document with the file type csv or txt-- >
.csv or .txt
Create a new testdata.csv, write a use case on one line, and separate multiple parameter values by default:
Case_name,id,attr,number
Case1,9,226,3
Case2,226,1
Case3,9,1
Case4,9226
3. Add and configure CSV Data Set Config configuration components
4. Replace the written data in the request with the variables defined in step 3
Data-- > ${varName}
For example, ${attr}
5. Configuration parameterization
5.1 set the number of threads to the number of use cases
5.2 the number of circular control requests
a. Add a loop controller and set the number of cycles to the number of test cases
b. Move CSV Data Set Config configuration components and requests under the loop controller
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 238
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.