There is no need to pressure the login operation at the same time, that is, I only need to log in once with a user and then loop through other business operations, in which case the login and query operations need to be placed in two separate thread groups
In the case of cross-thread groups that cannot be accessed directly, there are other ways to share cookie variables. Several methods have been tested, but the following is the simplest:
Through JMeterUtils. SetProperty and JMeterUtils. GetPropDefault method implementation
1. Add a beanshell postprocessor to the cookie generation request and add the following script to save the cookie in the Jmeter property parameter:
import org.apache.jmeter.util.JMeterUtils; JMeterUtils. SetProperty (" cookie_name ", "cookie_value");Copy the code
Cookie_name and cookie_value are replaced with your corresponding cookie name (without the COOKIE_ prefix) and cookie value, respectively
Add beanshell preprocessor to the request of another thread group that needs cookie and add the following script to fetch the value of cookie and store it in the thread variable:
import org.apache.jmeter.util.JMeterUtils; String value = JMeterUtils. GetPropDefault (" cookie_name "); Vars. The put (" cookie_name ", value);Copy the code
The cookie_name here is the same as the name set earlier.
You can then use ${cookie_name} in that thread group to get the value of the cookie, which implements cookie passing across thread groups.
Ps: this document copied in segmentfault.com/a/119000001…
Reference: blog.csdn.net/yangqingtao…
www.cnblogs.com/alansheng/p…