JMeter (10) parameterization

Source: Internet
Author: User

JMeter can be used to do interface, performance testing, the principle is to simulate the client to send a request to the server, the request contains two different conditions of the parameters, one is included in the URL, one is the request to send the parameters.

The parameters contained in the URL, for example: Http://blog.imyalost.com/index.php/2016/11/11/jmeter, the "2016/11/11/jmeter" parameter is a URL parameter.

Parameters that need to be sent in the request (only get requests are enumerated), for example: http://www.it315.org/counter.jsp?name=zhangsan&password=123, "Zhangsan" is the parameter name, "123" is the parameter value.

As for the POST request, it can be found in the JMeter script "parameters sent with request" and "Files sent with request".

PS: For the Get and post request methods, see the previous blog:http://www.cnblogs.com/imyalost/p/5630940.html

For parameters in the JMeter script, the local writing format of the parameter is $.

With regard to the parameterization of JMeter, there are 2 common methods:

Start by creating a new test script that you can record with the tool (Badboy) or manually

The interface for the login request is as follows:

Here we parameterize the login username password, write the username password to the TXT document, save in. dat format, the encoding type select UTF-8, because the configuration component--csv Data Set config is very strict in parameterized format, User name password one by one corresponding, separated by a half-width comma

Then put the saved. dat file into a disk on your computer, where I put the path: F:\jmeter\csvtest.dat

Here are two methods for parameterization:

First, borrowing function assistant

Click JMeter interface, function bar options → function Assistant dialog box →_csvread

CSV file to get values from | *alias: CSV files take a value path, that is, the file path that needs to be parameterized before writing here

CSV file column number | Next|*alias: File Starting column number: The CSV file column number is 0, the first is 0, the second column is 1, and so on ...

function String : The resulting parameterized parameters, can be directly referenced in the parameters of the login request, the first column user name, the Number field number is 0, the second column password, the function number field number 1, and so on to modify the use can

Replace the parameterized parameters, then modify the number of threads, execute the script, through the listener in the result tree request content, you can see the parameters of the request are parameterized data

Second, configuration components--csv Data Set Config

Click on the thread group to add the configuration component →csv Data set Config:

Description

Filename: F:\jmeter\csvtest.dat file name, save the parameterized Data directory, can choose relative or absolute path

File Encoding: Utf-8,f:\jmeter\csvtest.dat the encoding format of the file, save the encoding format as UTF-8 when saving

Variable Names (comma-delimited): user,pwd parameter name (such as: There are several columns of parameters, in this case to write a few parameter names, each name in the middle with a delimiter split, here user,pwd, can be used to refer to the variable name: ${user},${pwd}

Delimitet: defines the delimiter used to separate parameters in "Variable Names"

Allow quote data: the processing of full-width characters is garbled when the option is selected as "true"

Recycle on EOF? : whether to loop read-in, because the CSV Data Set config reads one line at a time, splits it into a number of variables and gives it to a thread, and if the number of threads exceeds the number of recorded rows in the text, you can choose to read from the beginning

true= when reading a file to the end, read the file again

false= stop reading a file when it is read to the end

Stop thread on EOF: when recycle on EOF is False (reads the file to the end), the process is stopped, and when recycle on EOF is true, this item is meaningless

When you are finished, write the parameter that you just generated into the value of the parameter:

The above is the parameterized method in 2, it is recommended to use the CSV control method (because the function helper parameterization function is weaker than it)

Compared to LoadRunner, JMeter Parameterization has the following differences:

1.jmeter parameter file The first row has no column name

2. parameter file encoding, as far as possible to save as UTF-8 (encoding problem when using the CSV Data Set config parameterized when the strict requirements)

3.Jmeter parameterization is not loadrunner done well, it is dependent on thread settings (only the CSV Data set config Parameterization method only)

JMeter (10) parameterization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.