I'm working on some JMeter test plans that employ BeanShell assertions. Within these assertions I want to acess some user properties. There are several ways to access them:
JMeterUtils.getProperty("propertyName")
${__P(propertyName)
props.get("propertyName")
Where are the differences and what are the pros and cons of each option? Are they wrapper of each other or do they have specific functionality?
Thank you!
Functionally they are all exactly the same. They are even implemented the same way - they all call the getProperty()
method on the current jmeter properties object.
The difference is where you use them.
The ${}
notation is used when putting variables into JMeter GUI text boxes. In the fields on the HTTP sampler for example. note that __P
is shorthand for, and exactly the same as __Property
props.get()
is used in beanshell scripts, without having to explicitly import JMeterUtils
. You can also combine 1&2 to do ${__BeanShell(props.get())}
If you do import JMeterUtils
in beanshell, or you're developing a custom java class, then you would use JMeterUtils.getProperty()
.
Of the three, I would think #1 is the most efficient because it doesn't need to instantiate and evaluate beanshell