JMeter - Set a dynamic variable for Loop Controller

戏子无情 提交于 2019-12-13 06:27:05

问题


I have the following Setup:

| Thread Group
| -- BeanShell PreProcessor
| -- Loop Controller

In The BeanShell PreProcessor I have:

vars.put("myDynamicNumber", someDynamicallyGeneratedNumber+"");

In The Loop Controller I have:

Loop Count: ${myDynamicNumber}

I was under the impression this would work. Instead the Loop Controller cannot find the variable. Am I doing something incorrectly?


回答1:


You need to use Beanshell Sampler, not Beanshell Pre-Processor.

I don't know why does JMeter allow putting Beanshell Pre-Processor at the same level as loop controller, it should go as a child of i.e. HTTP Request.

I'd also suggest to slightly change your code to be:

vars.put("myDynamicNumber", String.valueOf(someDynamicallyGeneratedNumber));

Which is more correct from Beanshell perspective.



来源:https://stackoverflow.com/questions/20659274/jmeter-set-a-dynamic-variable-for-loop-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!