jmeterjsr223

Getting Jmeter property value with jmeter functions


I get some variable from user.properties to use JSR223 Sampler. In JSR223, I can use as variable such as ${count}, but if this variable pass ${count} to property file, it uses ${count} string instead of value of count variable.

Example:

user.properties: enter image description here

In jsr223 sampler:

log.info(props.get("key"));

output => 2023-07-10 12:52:56,884 INFO o.a.j.p.j.s.J.JSR223 Sampler: ${count}

while define count var as 3, jsr223 sampler use ${count}, I want display 3 in log.


Solution

  • No, the value in user.properties will be loaded at the starting time, not in the JMeter runtime. Therefore, the value of key is literally ${count}.

    You can override this value at runtime when using ${__setProperty(key,4,)} in UI element or props.put("key",5); in script element (JSR223 Sampers).

    Or set value through command line: jmeter -n -t test-paln.xml -Dkey=6