Jmeter attributes and variables

jmeter variable properties and which can be simply understood as programmed global and local variables. Property is globally visible across the thread group transfer calls, and basically variable can only exist in a thread group (variables defined in the test plan is passed across the thread group). Data transfer within the same thread group with the general variable, e.g., a temporary storage process value. A plurality of processes common set of attributes for general use, e.g., session login operation value required to pass with the other thread groups, each thread group to avoid repeated log.

Create and assign attributes and access methods are as follows:

1. Create a property and assignment:

Method 1: Use the built-in objects beanShell props, props.put ( "attribute name", "attribute value");

Second way: $ {__ setProperty (cookie3, $ {COOKIE_session})};

Method Two properties by creating function setProperty (jmeter typically by $ {__ function name (parameter)} invoke the function). cookie3 attribute names to be created, and the second parameter indicates the property value will be given.

Note: The attribute names and values ​​of parameters setProperty function does not need the quotes, or the quotes are part of the attribute name or attribute value as jmeter. For example, $ {__ setProperty ( "cookie3", $ {COOKIE_session})} created after the implementation of a property called "cookie3" rather than cookie3 attributes and attribute names and values ​​can not exist in a space between two parameters, otherwise the space will It is considered part of the property value assigned to the property.

2. Access to the property in the other thread Group:

Method a: {__ P (attribute name)} $ read by function;

Method two: {__ property (attribute name)} $ read by function;

Three ways: using the built-in object BeanShell get props.get ( "property name");

NOTE: If the attribute is assigned by the variables, e.g., $ {__ setProperty (session, $ {cookie})}, the set of cross-thread at this time and the reading session attribute used in the above process BeanShell script, the read value to "$ {cookie}", rather than the $ {cookie} corresponding variable values ​​(but read the session attributes in the same thread group is able to correctly read variable values, possible reasons: the guess is cross-thread group access property, read less than $ {cookie} cause, after all variables can not cross-thread group transfer, except for variables defined in the test plan). However, in some controls jmeter in the case of cross-process group that it can be read directly to the property by variable assignment, such as http cookie manager, user-defined variables controls.

Creation and assignment and access variables:

1. Create a variable and assign:

Method 1: Create controls jmeter provided;

Second way: use vars object is created in the script, vars.put ( "variable name", "variable value");

2. Access variables:

One way: variable name $ {}

Second way: vars.get ( "variable name")

 

Guess you like

Origin www.cnblogs.com/wuzm/p/10949728.html