Jmeter如何遍历单个线程组或控制器中的不同属性列表? [英] Jmeter how to loop through a list of different properties in a single thread group or controller?

查看:20
本文介绍了Jmeter如何遍历单个线程组或控制器中的不同属性列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过一组固定控制器的不同属性进行基本循环?循环控制器运行一组组一定次数,但不使用属性.

How to do a basic loop through different properties for a fixed set of controllers? Loop controller runs a set group a certain number of times, does not use properties though.

我可以做模块,并将值设置为多线程组使用的属性,但是如何传递属性的下一次迭代,并再次运行循环?

I can do modules, and set the values to properties for multi thread group usage, but how to pass the next iteration of the property, and run the loop again?

property x
do module (points to controllers)
next property

假设我有一个包含 44 个字符的列表,我想在进行测试时遍历 ${name} 中的这些字符.我非常不想为一次角色更改构建 44 组控制器.

Say I have a list of 44 characters, and I want to loop through those characters in a ${name} while I'm doing a test. I'd very much not like to build 44 sets of controllers for one character change.

请注意我无法向我的计算机添加额外的文件.它必须通过库存可用的控制器工作.我正在使用 Jmeter 2.4 r961953

Please Note I cannot add extra files to my computer. It has to work via the stock available controllers. I'm using Jmeter 2.4 r961953

谢谢

推荐答案

我将稍微详细说明 BeanShell 方法.我的假设是您希望在一个用户线程中执行此操作,如果是这样,我的建议是:

I will elaborate slightly more about the BeanShell method. My assumption is that you'd like to do it within one User Thread, if so my proposal would be:

创建一个循环控制器.

  • 逻辑控制器->回路控制器

循环控制器中添加以下条目:

  • 配置元素 -> 计数器
  • 预处理器 -> BeanShell 预处理器
  • 采样器 -> 你的采样器

Counter 元素将用作索引,用于从我们的数组中选择有效值,因此我们需要为 Reference Name 指定一个 Reference Name>Counter - 假设它将是 loopCounter.

The Counter element will be used as an index that will be used to choose valid value from our array, hence we need to specify a Reference Name for the Counter - let's say that it will be loopCounter.

现在我们必须切换到 BeanShell 预处理器并定义值数组.一个很棒的事情是我们有 vars 变量可用,它使我们可以 CRUD 访问场景中使用的变量:

Now we have to switch to BeanShell preprocessor and define the array of values. A great thing is that we have vars variable available and it gives us CRUD access to variables used in the scenario:

String[] varArray = {"Value1", "Value2"};
idx = Integer.parseInt(vars.get("loopCounter"))-1;
vars.put("myVariable", varArray[idx]);

最后一步,在 mySampler 中,我们可以以常规 JMeter 方式使用变量:${myVariable}

And for the final step, inside mySampler we can use a variable in a regular JMeter way : ${myVariable}

JMeter API 会非常有帮助.

这篇关于Jmeter如何遍历单个线程组或控制器中的不同属性列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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