Apache JMeter is an open source testing tool. JMeter functions to analyze and measure the performance of web applications with a variety of other services. The GUI mode of JMeter is perfect for adding and editing new configuration elements, thread groups, and samplers as a result of which you can view a number of different listeners helping for debugging.
However, the GUI mode does have a limitation which slows down the CPU utilization while running the recorded script. If we are running multiple listeners in a script, it affects the JMeter performance. To overcome such a situation, the script should be run in the non-GUI mode. There is a benefit to drive more requests per second out of JMeter in non-GUI mode.
Why to use JMeter in Non GUI/command line mode:
- Increasing threads (after certain limit) due to which JMeter crashes in the GUI mode.
- For heavy test scenarios (ex: shopping application: login-view product-add to cart-view bill-remove product-pay bill) JMeter consumes memory and CPU and it may affect your test results.
- To increase JMeter capabilities, i.e. to get more requests per second.
Running JMeter in command line mode:
Running JMeter using command line in non-GUI mode is very simple.
- Open command prompt
- Go into JMeter’s bin folder
- Enter following command, jmeter -n –t test.jmx -l testresults.jtl
jmeter -n –t test.jmx -l testresults.jtl
-n: It specifies JMeter is to run in non-gui mode
-t: Name of JMX file that contains the Test Plan
-l: Name of JTL(JMeter text logs) file to log results
-j: Name of JMeter run log file
Other than these options, JMeter has several other parameters that can be used for running in the non-GUI mode.
-R: list of remote servers,
-H: proxy server hostname or ip address
-P: proxy server port
View test result:
Once your test is complete, you will see the following display:
After completing the test, a JTL file will be generated at jmeter2.12/bin folder
Follow below steps to view test results from the resultant JTL file.
- Open JMeter in GUI mode.
- Add any listener Eg. View Results Tree.
- Click Browse button of the file name field in listener.
- Open testresult.jtl file.
- You should be able to see the result in listener now.
Would love to address questions from the readers. Kindly post them in the comments section below.