It says it right there when you start JMeter: “Don’t use GUI mode for load testing !, only for Test creation and Test debugging.”
The JMeter developers were even kind enough to include an example of how to call JMeter on the command line:
jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder]
This is a good start, but the real power in running JMeter from the terminal comes when you can set your test parameters at run time by passing them as properties. For example, you might want to run the same scenario with various thread counts or for a different number of iterations. You can even use command-line properties to toggle multiple test scenarios.
I have a file here that demonstrates a few of these usages (requires the Dummy Sampler plugin).
Property Default ENV QA THREADS 5 LOOPS 5 DO_A 1** DO_B 1**
** If no default value is given to the __P function, then the default is 1 (see here).
Use -J to set these values from the command line, for example:
jmeter -n -t PropExample.jmx -l stage.csv -J ENV=Stage
This will result in 5 threads doing 5 iterations of the “Stage-Sampler”. Note that for SamplerA or SamplerB to run, DO_A or DO_B must be explicitly set to “True”.
jmeter -n -t PropExample.jmx -l stage_a.csv -J THREADS=10 -J DO_A=True
This command will produce 10 threads doing 5 iterations of “QA-Sampler” and “SamplerA”. You can use the JMeter GUI to load a result log into any Listener node to see exactly which samples were run and how often.
If you are running a remote test, pass the property values to the worker scripts using -G.
jmeter -n -t PropExample.jmx -R server_1,server_2 -G THREADS=100 -G LOOPS=50 -G DO_B=True
This will start 100 threads each on server_1 and server_2 that will do 50 iterations of “QA-Sampler” and “SamplerB”.
Hopefully this will give you some ideas on how you can incorporate properties into your JMeter scripts to create flexible scenarios that you can run in multiple environments.