How to run JMeter from Command Line (non GUI mode) | QAProvider.com
Subscribe me on new discussions

How to run JMeter from Command Line (non GUI mode)

Views: 129

Why to execute non-GUI mode ?

  • GUI : consumes more resources / memory
  • GUI : not recommended for heavy load testing
  • Command Line : can be integrated with other systems -Jenkins etc.

In short GUI mode is not good for heavy load testing, since it consumes a lot of memory and resources. GUI mode of JMeter is designed for test recording, development and debugging purpose. So, it is recommended to do the performance testing in non GUI mode(using command line) in JMeter.

Even the official page of JMeter recommends us to use non GUI mode for load testing. Check here

Step 1 : Create Test Script

  • Create the test script in JMeter. Click here to see how to create test cases in JMeter.
  • This is the sample test script that I have created for the test.
  • Save the file in your preferred location. I have saved it to "E:\New folder\apache-jmeter-5.1.1\JMeterProject\Test.jmx"
  • Don't add listeners because we'll run it through Command Prompt.

Step 2 : Open Command Prompt

  • Open command prompt and go to the bin folder of JMeter.
  • Once we reach bin folder, we need to type this command,
  • jmeter -n -t (location of your jmeter test script) -l (location of the result file)
  • For MAC & Linux users the command will be sh jmeter -n -t (location of your jmeter test script) -l (location of the result file)
  • -n :  non gui mode
  • -t : location of jmeter script
  • -l : location of result file
  • For me, the location of the JMeter script is "E:\New folder\apache-jmeter-5.1.1\JMeterProject\Test.jmx" 
  • I will store the result in a CSV file , so I need to create a blank csv file . I have placed the csv file in "E:\New folder\apache-jmeter-5.1.1\JMeterResult\Result.csv" 
  • The final command will be jmeter -n -t "E:\New folder\apache-jmeter-5.1.1\JMeterProject\Test.jmx" -l "E:\New folder\apache-jmeter-5.1.1\JMeterResult\Result.csv"
  • Tap Enter & wait for the test to execute.
  • There are some more commands that you may need, jmeter -h : to get help on JMeter commands & jmeter -? : to get information on JMeter command options.

Step 3 :Check the CSV file

  • After the test is executed we can see that the blank CSV file we created earlier , now has the results of the test inside it.

 

In this tutorial we have learnt about the consequences of using JMeter in GUI mode & to avoid such problems how can we use non-GUI mode to run JMeter tests & reduce usage of memory/resources. This is just a simple HTTP test but can be done for all type of tests.

Thank you.

Karma: {{ total }}
Published: 4 months ago by Raja