Multi-threaded data sharing, such as cookie

1. Add the regular expression extractor at http request:

2. add at request Bean Shell PostProcessor (post-processors bean shell);

Parametres: the need to pass parameters to the operation of Bean Shell PostProcessor. Front extracted cookie value, writes a cookie to put parameters

Script: string cookie = bsh.args [0]; parameter value received Bean Shell PostProcessor, assigned to a parameter. 0 is the first value.

                 $ {__ setProperty (newcookie, $ {cookie},)}; call functions __setProperty, the values ​​of the parameters in the cookie Bean Shell PostProcessor is assigned to newcookie, and to set newcookie jmeter built-in properties.

2. Other references thread group ---- $ {__ P (newcookie,)}

 

 

Jmeter between the thread group is independent, each thread group independently of each other, so the output parameters A thread group is not directly called group B in the thread.

But sometimes in order to facilitate the management, we may be stored separately to each interface in a different thread groups. Take Cookie, although each thread group we can put in a logon request, and then outputs a Cookie for the group to use this thread, but this is more tedious and redundant. At this point we can use cross-thread group to pass parameters to solve this problem;

Ideas: The variables in a thread group by "__setProperty" global variable jmeter function provided in another thread group by "$ {__ P (parameters,)}" function call.

Description: jmeter own built-in function in, "__ setProperty" ($ {__ setProperty (newtoken, $ {cookieKey},)}) function can set the value of a parameter into jmeter own built-in property, and jmeter built-in property of all threads group can be called, it is a global variable. When each thread group call, "$ {__ P (parameters,)}" to call the corresponding attribute can simply use function calls jmeter properties.

1. Add the regular expression extractor at http request:

2. add at request Bean Shell PostProcessor (post-processors bean shell);

Parametres: the need to pass parameters to the operation of Bean Shell PostProcessor. Front extracted cookie value, writes a cookie to put parameters

Script: string cookie = bsh.args [0]; parameter value received Bean Shell PostProcessor, assigned to a parameter. 0 is the first value.

                 $ {__ setProperty (newcookie, $ {cookie},)}; call functions __setProperty, the values ​​of the parameters in the cookie Bean Shell PostProcessor is assigned to newcookie, and to set newcookie jmeter built-in properties.

2. Other references thread group ---- $ {__ P (newcookie,)}

 

Guess you like

Origin blog.csdn.net/qq_35577990/article/details/93735493