Beardy Geek – Web Development Blog

A blog about web development – giving tips and tutorials about all aspects of web dev.


Beardy Geek – Web Development Blog

JMeter testing from the command line

I recently did a video post about website stress testing using JMeter.  Moving on from this, I’m going to show you how you can run JMeter tests from the command line, without using the GUI.

Why use the command line?

The main reason to use the command line is the most obvious: you don’t have a gui available.  If you want to run stress tests from a server, you’ll need to do it from the shell.

So why would you want to run the tests from a server?  Well one issue I discovered while running some tests on a media server recently, is that testing from your home machine means at some point during the test, you’re going to run out of bandwidth.

Of course you can just let JMeter loose with lots of threads and not record the responses, but it’s useful to know the response results of your pages or media, which means a download of the page or media you’re testing.

Using JMeter without a GUI

The JMeter binary allows you to run in GUI-less mode, using the -n option.

  1. Create your test in the JMeter UI as usual.
  2. Upload the JMX file to the server.  This contains all the configurations for your test that you just setup.
  3. Run the jmeter command:
    jmeter -n -t mytest.jmx -l log.jtl
  4. The test will run, and save the output in the log.jtl file.
  5. Download this file, and open it inside the JMeter UI.

If you need to change elements of the test, you can edit the JMX file directly.  It’s stored in an xml type format, so it’s fairly easy to see what you need to change.

Want to learn more about JMeter?  Check out this book on JMeter Testing

FacebookTwitterGoogle+LinkedInRedditStumbleUponShare