-JMeter parametric performance testing (1) CSV Data Set Config

A parametric definition

The so-called parametric data, the client is sent to the server process to a process of pre-stored parameters.

Generally, for a functional test, when the same function with a different test data, we can use the parameters of the test to streamline;

For performance testing, special restrictions (such as the unique data requirements) In order to simulate the real behavior of multiple users or operating system to cope with multiple simultaneous users, we need to use parameterized to solve these problems.

JMeter provides a lot of ways and means of parameterization, common are:

Configuration elements CSV_Data_Set_Config

2. Built-in parametric functions, such __CSVRead ()

This section 1 we mainly speak at CSV_Data_Set_Config parameterization.

Configuration Item

Configure the CSV Data Source:

1.Filename:

Path or file name of the data to be read. You can use absolute or relative path.

When using a relative path represents a file path, the test program directory to the current directory.

When operating in distributed mode JMeter, parametric data files need to be copied to each Slave, and set to the same directory structure.

2.File Encoding:

If the operating system is not set up places of character encoding to read the data file. You can specify in what to read coded data files to prevent garbled.

Such as the operating system default character encoding is GBK, and the data file (CSV file) is encoded as UTF-8, is read out as garbled data is certainly, in this case to set the File Encoding to "UTF-8" can be read successfully .

3.Variable Names(comma-delimited):

A list of variable names used to store the data file column values. With between variable name, (comma). If the variable name list is empty, the first line of the data file JMeter will each field value as the name of each variable (whether or not ignore the first row).

Such as the data file has the following two lines Found:

Joe Smith, Male, 25

John Doe, Female, 20

Without setting a variable name list, three values ​​will be the first line as a variable name:

Joe Smith, Male, 25

Zhang} {$, $ {M}, {20} $ values ​​are: John Doe, female, 20

4.Ignore first line (only used if Variable Names is not empty):

Whether or not ignore the first line of the data file. This option is only set up a list of parameter names when working.

Select True to ignore the first row, select False indicates not ignore the first row. Generally used when there is a column header in the data file, because the title is not a value, it is considered negligible

first row.

Such as the data file has the following values:

name,sex,age

Joe Smith, Male, 25

John Doe, Female, 20

If this is set to False, it will be name, sex, age as a variable value read, set to True will ignore this line, start reading from the second row.

5.Delimiter (use'\t'for tab):

Data file delimiter field. The delimiter saving split records to the defined variables. The default value, (comma).

6.Allow quoted data?:

Value data file are allowed to use double quotes. True indicates allowed, False representation is not allowed.

Is generally used when the value is included in the delimiter, the value may be considered enclosed in double quotation marks, separator shield special meaning.

For example, records the product number, name, price data files:

goods_id,goods_name,price

1,Watch_wanguo,"1,500,000"

If you do not use double quotes, commodity price of 1, use double quotes, commodity price

1,500,000

7.Recycle on EOF?:

Read incoming data file (EOF ie end of file) at the beginning of the file back to whether a re-read.

True read cycle, False not read cycle.

8.Stop thread on EOF?:

Reads the data file reaches the end, whether to stop the thread. True stop the thread, no further testing;

False thread does not stop, continue to run the test cycle value.

9.Sharing mode:

Sharing mode. All threads all threads, Current thread group of the current thread group, Current thread of the current thread.

1)All threads:

All threads share the same file. In the test data file is opened only once, each thread reads the parameter values ​​for different lines.

Value and thread each thread starts to read the order related; whether or not reference parameters threads, each thread is assigned a parameter value.

2)Current thread group:

The current thread group. Each thread group under test plans to open a parameter file separately.

3)Current thread:

The current thread. Each thread open a parameter file separately. In this mode, if each thread need to focus on values ​​from different values,

You may be provided with a set of parameters of the data file, one file for each thread. The thread number associated with a data file name up to it.

For example, a group of files as follows:

testdata1.csv, testdata2.csv ...,

testdatan.csv

Thread number by $ {built-in functions to obtain threadNum}, then the data file name can be set: the Testdata $ { threadNum} .csv.

for example:

Here introduced in earlier queries being purchased total amount of interface as an example to explain:

Parameterization steps:

1. Determine which interface parameters required request parameters parameterization

When designing test cases, we have to prepare the data for the product number, product specifications, quantity,

So the id, attr, number parameterized

2. The external test data in a document is saved, the file type csv or txt ->

.csv or .txt

Create a TestData.csv, a write line use case, a plurality of parameter values ​​by default, the partition:

case_name,id,attr,number

case1,9,226,3

case2,,226,1

case3,9,,1

case4,9,226,

3. Add and configure the configuration elements CSV Data Set Config

4. replaced with a third variable in step as defined in the data write request dead

data --> ${varName}

For example $ {attr}

The configuration parameters of

5.1 The number of threads to the number of use cases

5.2 times control request cycles

a. Add a loop controller, which is provided for the number of test cycles

b. Place CSV Data Set Config element arranged to move with the cycler following request

Guess you like

Origin blog.51cto.com/14645850/2462732