问题描述
我有ThreadGroup1,该线程执行登录操作,该操作使用CSV数据集配置从CSV文件获取凭据,并将用户名和密码保存在两个不同的变量中,例如:
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})}
现在在ThreadGroup2中,我使用以下凭据:
Now in ThreadGroup2 I use these credentials using:
${__property()}
它对于单个用户来说效果很好,但是如果我尝试多个用户(请求),则最后一个值将覆盖先前的所有值,并且ThreadGroup2仅接收定义的最后一个凭据.
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.
我希望将所有凭据一一传递给ThreadGroup2,然后ThreadGroup2中存在的请求应分别根据所有这些凭据工作.
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.
这怎么办?
PS:我定义了加速周期= 1,用户数= 3,循环= 1.
PS: I defined ramp-up period=1, Number of Users=3, loop=1.
推荐答案
我想知道您是否真的需要两个单独的线程组?
I'm wondering if you really need two separate ThreadGroups?
似乎您只需要一个ThreadGroup,您应该在其中执行登录操作,然后将用户/传递参数保存在 vars 中,而不是在 props 中.变量是线程局部的,因此一个线程的值不会覆盖另一个线程的值.
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.
您可以在脚本vars.put("var_name", "var_value")
中设置变量,然后像${var_name}
一样使用它. 另一个设置变量的选项.
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.
这篇关于在ThreadGroups之间传递多个值-Jmeter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!