Update Jmeter variables with beanshell

老子叫甜甜 提交于 2019-12-01 01:11:38

I do not see any issues in your script. It should work fine.

Remember that all these beanshell variables are specific to the thread. Ie, If Thread1 increments it to 2, the current value of 'counter' for the Thread2 will still be 1.

I think you run your test for more threads/users with only one iteration. This is why it prints 2 for all users. If you have more loop counts/set it to forever, counter will get incremented.

You can upload your jmx file if it still does not resolve the issue.


EDIT:

I just checked your jmeter test. Even though you increment the counter value by 1 in the Beanshell Sampler, Yolu are setting the counter back to 1 as part of User Parameters. Remove it. After removing them, It works fine for me.

Put the cookie manager in your script and you will be fine.

Now you have a global variable counter = 1, in one request you use a local variable counter ant set it to 2. When another request tries to pick up the value of counter it gets the global value 1, because the local one is trashed.

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