问题描述
我正在尝试用 jMeter 做一些测试.
I am trying to do some test with jMeter.
我有带有 url 的 CSV 文件,想遍历所有这些文件并发出 HTTP 请求.我通过在循环计数字段中的线程组中输入确切数量的 url 来实现这一点.
I have CSV file with the urls and want to iterate over all of them and make HTTP Request. I have achieved that by typing exact number of urls in the ThreadGroup in Loop Count field.
是否有可能以这种方式设置 jMeter,它会循环遍历 url,而无需在 ThreadGroup 中键入 url 计数?任何控制器都可以做到这一点?
Is there any possibility to set jMeter in that way it will loop over the urls without the need to type count of the urls in ThreadGroup? Any controller can do this?
推荐答案
您可以在 csv 数据格式中定义 url,并让 Jmeter 循环通过它.
You can define the urls in the csv data format and have Jmeter loop through it.
可以使用 CSV 数据配置来定义和加载 csv 文件.
变量名代表 csv 文件中的每一列,可以在循环控制器中引用.
The csv file can be defined and loaded with the CSV data config.
The variable names stand for each of the columns in the csv file, and can be referred in the loop controllers.
示例:
- 定义一个while控制器,条件为
${url}
- 定义一个子
CSV Data Set Config
,包含文件路径和变量名url,代表列出url的列. - 使用
${url}
和 http 请求处理程序来触发请求. - 要在到达 CSV 文件末尾后停止执行:在
CSV 数据集配置
中设置Recycle on EOF?= False
和在 EOF 上停止线程?= 真
.
- Define an while controller with the Condition as
${url}
- Define an child
CSV Data Set Config
, with the file path and the variable name url which stands for the column listing the urls. - Use the
${url}
with the http request handler to fire the request. - To stop execution after the end of the CSV file is reached: within the
CSV Data Set Config
setRecycle on EOF? = False
andStop thread on EOF? = True
.
这篇关于jMeter 循环遍历 CSV 中的所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!