在Groovy中无迭代器遍历对象

时间:2019-02-06 14:20:24

标签: groovy jmeter

我尝试在不使用next()迭代器获取特定值的情况下迭代对象。

Recordset recordset=connection.executeQuery(strQuery);

我目前使用recordset.getField("Col1"); recordset.getField("Col2");访问变量。我尝试在JMeter内的Loop Controller中逐行用完内容,

1 个答案:

答案 0 :(得分:1)

您具有Recordset的inRowNum属性,可用于“告诉”记录集要跳入的行。

鉴于您具有以下Excel文件:

enter image description here

  • 如果您调用recordSet.inRowNum=0-它会显示A2B2
  • 如果您调用recordSet.inRowNum=1-它会显示A3B3
  • 可以像vars.get('__jm__Loop Controller__idx')那样获得当前的Loop Controller's迭代

演示:

enter image description here

参考文献: