JMeter CSV Dataset Config:如何在同一个线程中移动变量? [英] JMeter CSV Dataset Config: how to move through variables in the same thread?

查看:26
本文介绍了JMeter CSV Dataset Config:如何在同一个线程中移动变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm using a CSV dataset config element, which is reading from a file like this:

abd
sds
ase
sdd
ssd
cvv

Which, basically, has a number of 3 letter random string.

I'm assigning them to a variable called ${random_3}.

Now, I want to use values from this list multiple times within the same thread, but each time I want to move to next. For example, I want the first sampler to use abd, the 2nd to use sds, then ase, etc. But if I just use ${random_3} then only the first one (abd) is used wherever it's referred to. Is there a way I can specify to loop through the values from the CSV dataset within a thread?

解决方案

CSV Data Set Config works fine for this. All of the values need to be in one column in the file and assign them to the variable as described.

Create a Thread Group that has as many threads for as many users as you want iterating over the file (i.e. acting on the HTTP Request). Assuming 1 user, set the number of threads to 1, loop count to 1.

Inside the thread group you will need to add a Loop Controller or a While Controller. You indicated that you want to loop through the whole data set. If you add a loop controller you will want to set the Loop Count to 6, since you have 6 values, one for each value. Alternately (and easier for processing the whole file) add a While Controller instead of a Loop Controller and set ${random_3} as the while condition.

It is important to set the CSV Data Set Recycle on EOF and Stop Thread on EOF values correctly. If you plan to iterate over the file more than once you must set "Recycle on EOF" to True (i.e. instruct jMeter to move back to the top of the CSV file). Set "Stop Thread on EOF" to False if you are using a loop controller, true if you are using a while controller and want to stop after reading the whole csv dataset.

Add the CSV Data Set Config as a child of the controller along with the HTTP Request. View the results using any listener you want to use.

这篇关于JMeter CSV Dataset Config:如何在同一个线程中移动变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆