如何从Jmeter的get属性中提取值并将其另存为变量。这些值将在api调用中使用

时间:2019-03-07 22:04:58

标签: jmeter jmeter-5.0

getproperty values passed from Thread Group 1 to Thread group2

Result from BeanShell assertion

  • 第1步-使用jdbc请求从具有两列和多行的数据库中获取数据。
  • 步骤2-从线程组1,使用$ {__ setProperty(StateCodeProperty,$ {stateDetails})}将属性设置为数据库结果。

  • 步骤3-使用beanshell断言通过get属性访问线程组2-字符串result =(vars.get(“ $ {__ property(StateCodeProperty)}”)));我需要有关如何分隔列并在api调用中使用它的帮助。 –

1 个答案:

答案 0 :(得分:0)

无论如何,如果您想访问不同线程组中的数据库结果,那么您可以尝试在beanshell断言中执行类似的操作(虽然不确定)-

ArrayList results = ${__property(StateCodeProperty)}; //it should return the object as an arraylist
for (int i; i < results.size(); i++) {     

    if (results.get(i).get("statecode").equals("NY")) { //iterating the results, 'statecode' is the name of your 1st column, similarly you can do for 'State'

        //Do your comparisons or whatever you like here             
    }      
}