JMETER user variable scope

JMETER when writing the script, we will use the variable scope of a variable is the thread.

We tested the following script about the variable return is a thread.

 

1. We first define a variable amount of flow.

 

2. Thread group uses three threads

3. Add a loop in the thread group controller, to perform 3 times.

Add a loop controller.

Add a beanshell sampler.

beanshell code is as follows:

int amount=Integer.parseInt( vars.get("amount"));
amount++;
vars.put("amount",String.valueOf( amount));
log.error("amount:" +amount);
return amount;

The role of the code of user variables accumulated, we can verify if the value of the accumulated value of the user variable, explanatory variables in the thread accumulated,

If every user iteration, starts from the initial value, then the variable is localized and user-thread-related.

4. Test results were as follows:

 

 Test found, each iteration, beginning from the variables are 3, accumulated in a thread to 5, from 3 then starts.

 

Guess you like

Origin www.cnblogs.com/yg_zhang/p/11494908.html