Jmeter configuration elements --CSV DataSet Config parameterization

Before talking CSV DataSet Config configuration elements, let's discuss why under parametric?

For example, in doing performance testing, we generally need to simulate multiple users to operate, in order to meet the actual scene, simulate real user behavior, we need to do simulate user account or other information is different, then we need use parameterized. Jmeter, the element can solve the problem.

Foreword

Jmeter element can be used for configuration parameters, initialization variables and the default values, and in response to the configuration information stored in database server links. JMeter parametric generally used CSV DataSet configuration element or the Config JDBC ConnectionConfiguration be parameterized. Today, the first to use CSV DataSet Config parameterization.

CSV Data Set Config element:

The element can be used to read data or dat csv file, and by providing the associated read data to save Jmeter variables, execl csv file can be edited to form the tool. Two types of documents to explain: txt file and csv file.

Basic Configuration

Interface Field Description:

Name, comment element before the same can be arbitrarily set.

Filename : refers to the directory where you saved the file information can be relative or absolute path, relative path from Jmeter startup directory (*** / bin) path.

Encoding File : file encoding, the default is ANSI, recommended setting is utf-8, to prevent met garbled situation.

Names Variable : Parameter name, the name of each intermediate divided by separator, the separator using the following "Delimitet" defined default separated by commas, the parameter corresponding to the parameter file. If the name of the parameter is greater than the parameter set in the parameter file, the value of the extra parameters fail to; otherwise parameter file corresponding to the parameters are no parameters.

Delimitet : custom separator, used to separate parameters in the file, and the name of the parameter defined in the above Variable Names.

The Data Quoated the allow? : Whether to allow reference data, set to True, the value of the parameter settings file must be enclosed in quotation marks, False is not required

ON EOF Recycle? : Encounters end of file, whether from scratch cycle to read, is set to True, the cycle continues from scratch

Stop Thread on EOF? : When Recycle on EOF set to False and True, record csv file is read Stop Thread on EOF after stop running

Mode Sharing : share mode parameter file, there are provided three, as follows:

Threads All : parameter files for all threads share the same test plan contains different thread groups.

The Thread Group Current : only the current thread group threads share.

The Thread Current : only get the current thread.

Interface is shown below:

Add the path elements arranged as follows:

to parameterize

We have a basic understanding of the configuration elements, then to practice a lot.

A parameterized: csv file

How to configure csv file?

Create a new xls file, then save as csv file.

This is very simple, we look at how to refer mainly to a csv file, to achieve the parameters of the effect.

① configuration interface

Let's look at the configuration interface, as shown below:

It should be noted, file encoding file encoding filled out the GB2312, not utf-8, needs extra attention, otherwise there will be garbled phenomenon, as follows:

② prepare csv file

Fill in the following contents of the file:

③ introducing parameterized

We fill in the configuration interface variable named keyword, so the introduction to the interface, but also with the variable name, as follows:

④ Check parameterization results

运行脚本,查看结果,如下所示:

接口每次请求,关键字都是不同的,就达到了参数化的效果。

参数化二:txt文件

我们了解csv参数化之后,对于txt文件参数化,都是类似配置。我们新建一个txt文本文件,输入内容并保存即可。

①配置界面

配置界面如下:

②注意点

file encoding文件编码填写的是utf-8,不是GB2312。需要格外注意的是,文本文件保存时,默认为ANSI格式文件,即可界面配置为utf-8,但还是会出现乱码的现象,如下所示:

配置为utf-8,还是会乱码,解决办法为:将txt文件另存为重新保存,选择文件格式为utf-8保存即可。

③准备txt文件

内容输入如下图所示:

④引入参数化

我们在配置界面填写的变量名为keyword,所以引入到接口中,也用该变量名,如下所示:

⑤查看参数化结果

运行脚本,查看结果,如下所示:

总结

无论是用csv文件还是txt文件进行参数化,配置方式都类似。需要注意的就是,文件编码的格式问题,配置错了,就会导致乱码的情况。配置项中,如果参数化文件第一行填写了参数名称,配置的时候,则需要忽略第一行。

 

本文仅代表作者观点,系作者@温一壶清酒发表。
欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
文章出处:http://www.cnblogs.com/hong-fithing/

Guess you like

Origin www.cnblogs.com/hong-fithing/p/12109888.html