2013-05-22

How to access Jmeter Properties ?

As we know previously , we can change jmeter properties by editing properties files stored in /bin directory. I have a full 18 posts for all type of property definitions. In this section , we will see that how can we read and write the properties while jmeter is running.

Jmeter has three build in function doing that. They are as follows
 
1.  ${__property(remote_hosts,myVariable,127.0.0.1)}


-It returns a value of jmeter property(remote_hosts). If the value is not present in the file, default value will be given.
- It has 3 parameter, first one is property name(mandatory) , second one is the variable name where to store, third one the default value of the property.
-If we do not use the 2nd and third one, it will give the value of the property.
Ex- ${__property(user.dir)} - returns user.dir value as string
-If we use 1st and 2nd parameter, the return value will be saved to the variable mentioned in2nd parameter. It is same if whether we use third one or not.
-Default is returned if there is no value.

Note : To get default values, we don't need to define function names or parameters.

2.  ${__P(remote_hosts,127.0.0.1)}

-This is same as previous one but we can not store in a variable. So, except the variable parameter, it has property name(mandatory) & default.
-If no default value give, it assumes 1(use for loop, thread and others)
-It is mainly used in command line to get the property values.

3.  ${__setProperty(remote_hosts,127.0.0.1,True)}

-This is opposite functionality as _property. We can set a property with values.
-It has 3 parameter, first one is property name(mandatory) , second one is the property value to store, third one shows whether we want to return the original value. So third parameter is True/False
-So, if we choose False, it will return a empty string.
 -It is used for changing property time to time after executing threads.

Thanks..:)

No comments:

Post a Comment