2017-08-15 124 views
1

我在setUp線程組下有一個BeanShell PostProcessor。 我把ArrayList中進入「bsh.shared」命名空間,如:JMeter - 如何在單個線程組中循環「bsh.shared」ArrayList?

List personIdsList = new ArrayList(); 
... 
bsh.shared.personIds = personIdsList; 

我知道怎麼讀通過__BeanShell功能價值爲:

${__BeanShell(bsh.shared.personIds)} 

我想通過這個數組中循環其他線程組。 ($ {} PERSONID - 它應該從列表迭代值)

enter image description here

你能不能,請告訴我該怎麼做?

謝謝!

回答

1

最簡單的方法將使用While Controller與像Counter測試元件一起:

  1. 添加在控制器到您的第二個線程組,並把下面的表達式爲「條件」區域:

    ${__BeanShell(Integer.parseInt(vars.get("counter")) < bsh.shared.personIds.size()-1,)} 
    
  2. 將計數器添加爲While控制器的子項並對其進行如下配置:

    • 開始:0
    • 增量:1
    • 最大:${__BeanShell(bsh.shared.personIds.size()-1,)}
    • 參考名稱:counter
  3. 請參閱「當前」人ID爲${__BeanShell(bsh.shared.personIds.get(Integer.parseInt(vars.get("counter"))),)} 在需要

演示: JMeter Beanshell Counter Demo

+0

非常感謝您的解決方案! 這是非常有幫助的,但我有一個問題。 在第1次迭代期間,計數器值未知。有沒有解決方案? – yarafed