Running JMeter in Non-GUI Mode
Running JMeter in Non-GUI Mode
JMeter Non-GUI mode is recommended for performance testing as it consumes less memory and runs faster than GUI mode. JMeter Non-GUI Mode is also called as command-line mode. Follow the below steps to run JMeter using command line in Non-GUI mode.
Open command prompt
Navigate to JMeter’s bin directory
Enter the following jmeter command
/> jmeter -n –t testScript.jmx -l results.jtl
JMeter Command-line Parameters:
The jmeter parameters are as follows:
-n → This specifies JMeter to run in non-gui mode
-t → The name of JMX file which contains the Test Plan [ex: testScript.jmx]
-l → This specifies JMeter to log results.
-j → Name of JMeter run log file (JMeter text logs) to log results.
Example:
/> jmeter -n -t C:\JMeter\scripts\load_test.jmx -l C:\JMeter\results\output.jtl
Remote execution
The below options are used for JMeter tests when using through a firewall/proxy server.
-r → Run the test in the servers specified by the JMeter property “remote_hosts”
-R → list of remote servers
-H → proxy server hostname or ip address
-P → proxy server port
-u → username for proxy authentication – when required
-a→ password for proxy authentication – when required
Example command to specify the firewall/proxy server hostname and port number information
/> jmeter -n -t testScript.jmx -l testLog.jtl -H test.proxy.server -P 8000
Example command with username/password:
/> jmeter -H test.proxy.server -P 8000 -u username -a password -N localhost
Proxy Settings can also be defined in a Test Plan, using the HTTP Request Defaults configuration or bu using HTTP Request sampler elements.
Generating an HTML Report
After running the test, generate an HTML report using:
/> jmeter -g results.jtl -o report_folder
Advantages of Non-GUI Mode
Some of the advantages of this mode are as follows:
- Consumes less CPU and memory.
- Faster execution of test plans.
- Ideal for CI/CD pipelines and automated performance testing.
- Always test your script in GUI mode before running it in Non-GUI mode.
- Use listeners like Summary Report in Non-GUI mode to analyze results.