Using Command Line Parameters in JMeter for Load Testing
Learn how to create performance test scripts using the command line mode in JMeter.
Join the DZone community and get the full member experience.
Join For FreeIt is a common practice to create performance test scripts by using the JMeter GUI. For test execution, however, it would be best to use the command line mode of JMeter. Whenever you need to change a parameter, like thread number, base URL, etc., you need to go to GUI mode, make modifications, and run your test. We can’t call that a good practice. JMeter lets you pass parameters in command line mode.
How to Pass an Argument via the Command Line
A basic command line parameter is
jmeter -n -t your_script.jmx
-n
— tells JMeter to run in non-GUI mode.-t
— specifies the path to source .jmx script to run.
In case you want to send parameters via command line, add the parameters below:
jmeter -n -t your_script.jmx -Jurl=www.abcdef.com -Jusername=canberk
Then you need to change your JMeter file. You can receive these parameters with a built-in function of JMeter. This function is ${__P(VariableName)}
.
This way, your test scripts are going to be dynamic in terms of parametrization.
How to Pass an Argument via Loadium
When you want to run your tests in Loadium, you can use the Advanced Settings tab in Create JMeter Test. Then you can add the necessary parameters. As a result, you don’t need to re-upload your scripts everytime you change something in the jmx file.
Happy load testing…
Please feel free to ask questions if you have any.
Published at DZone with permission of Canberk Akduygu. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments