Passing multiple values between ThreadGroups - Jme

2019-09-09 08:28发布

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.

3条回答
贪生不怕死
2楼-- · 2019-09-09 09:01

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.

查看更多
Juvenile、少年°
3楼-- · 2019-09-09 09:03

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.
查看更多
Evening l夕情丶
4楼-- · 2019-09-09 09:04

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.

查看更多
登录 后发表回答