Passing multiple values between ThreadGroups - Jmeter

本秂侑毒 提交于 2019-12-12 03:44:06

问题


I have ThreadGroup1 which performs login operation where it is getting Credentials from CSV file using CSV Dataset Config and saves username and password in two different variables like:

${__setProperty(USERNAMEGlobal, ${USERNAME})}
${__setProperty(PASSWORDGlobal, ${PASSWORD})}

Now in ThreadGroup2 I use these credentials using:

${__property()}

it works fine for a single user, but if I try multiple users (requests) last value overrides the previous all values and ThreadGroup2 receives only the last credentials defined.

I want all the credentials to be passed one by one to ThreadGroup2 and then the requests present in ThreadGroup2 should work according to all those credentials respectively.

How this can be done?

PS: I defined ramp-up period=1, Number of Users=3, loop=1.


回答1:


There are some options:

  • Inter-Thread Communication.
  • Put them to different properties:

    ${__setProperty(USERNAMEGlobal1, ${USERNAME1})}
    ${__setProperty(USERNAMEGlobal2, ${USERNAME2})}
    etc.
    
  • Initialize array with all usernames, stringify it and then put to property. However, it looks like a hack that will slow your plan.



回答2:


Looks like you can save all the username-password pairs into file csv-file in ThreadGroup1 and then re-use they in ThreadGroup2 via e.g. reading with CSV Data Set Config.




回答3:


I'm wondering if you really need two separate ThreadGroups?

It seems like you need only one ThreadGroup inside which you should perform your login actions and then save user/pass parameters in vars, not in props. Vars are thread local, so values of one thread won't override values of another.

You can set variable within the script: vars.put("var_name", "var_value"), and then use it like ${var_name}. Another option to set variable.



来源:https://stackoverflow.com/questions/14353498/passing-multiple-values-between-threadgroups-jmeter

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