Jamie Piltz
Jamie Piltz

Reputation: 205

Using empty properties in JMeter's Non-GUI Mode

I've been trying to create a simple test scenario in JMeter using the Non-GUI Mode (Command Line) with some configurable parameters. I was hoping that I would be able to omit the value of some of the properties but it didn't work how I had hoped.

Below is the command I'm using to run the tests:

[JMETER_HOME]\bin\jmeter.bat -n -t example\test.jmx -p shared\resources\jmeter.properties -q example\resources\user.properties -l example\results\result.jtl -JUSERS=1 -JRAMPUP=0 -JLOOPS=1 -JDURATION= -JSERVER=www.google.com.au -JPORT= -JURL=maps/

I would like to specify a more that one default values for a few of these fields. I would like the JMeter to try to first use the command line properties, then try to use the user.properties and then finally have a default value.

Something like ${__P(PORT,${__property(port)},"")}

Upvotes: 0

Views: 2222

Answers (2)

kares
kares

Reputation: 7181

${__P(PORT,"")} won't work as expected (JMeter 3.1) but ${__P(PORT,)} does the trick

omitting the second parameter (${__P(PORT)}) defaults to 1 ... which is rarely a desired result.

Upvotes: 2

olyv
olyv

Reputation: 3817

I am not sure you can make JMeter try to use value of variable entered from console then user and finally default value. But you can make it use value from console and if no value entered in console then JMeter uses default value. To achieve that you should specify value of you user defined variable as ${__P(name_of_parameter_from_console,default_value)}. http://blog.novatec-gmbh.de/how-to-pass-command-line-properties-to-a-jmeter-testplan/

Upvotes: 0

Related Questions