Run massively scalable performance tests on web, mobile, and APIs

Request a Demo
May. 17th, 2016

How to Get Started With JMeter: Part 1 - Installation & Test Plans

 

Apache JMeter is the leading open-source tool for load and performance testing.
 

For those of you just getting to grips with JMeter, we’ve put together a three part ‘how to’ series on how to use this powerful tool. (Note: if you’re already a JMeter pro, you might want to take a look at this webcast on creating advanced load testing scenarios)

 

This week we’ll focus on installing JMeter and creating test plans. Over the next few weeks, we’ll be tackling how to build test scripts, set up workflows and  run reports and analytics.

 

Step 1: How to Install JMeter

 

It’s important to always use the latest JMeter version. This is currently JMeter 3.2.

 

Here are the steps you should take:

 

  1. Install the latest 64-bit JRE or JDK. This is needed as JMeter is a pure Java application.
  2. Go to Apache JMeter and find the Binary to download to your computer
  3. Once downloaded, move this file to your preferred location, extract it and go to the folder and then the bin directory.
  4. Take a look at the directly. You should see a series of scripts which can run JMeter in various modes.

 

Congratulations! You have all you need to start working on your test plan.

 

Quick note: Although JMeter 2.13 has all the files you need to build and run most tests, there are some exceptions. Check out the JMeter website for more information.  

 

 

Building Your First JMeter Test Plan

 

Launch JMeter by switching to the “bin” directory and typing the following:
 

  1. For Mac/Linux/Unix: ./jmeter.sh
  2. For Windows: jmeter.bat
     

You should now see an empty test plan (like in the image below):
 

JMeter Test Plan

 

Don’t see the JMeter GUI yet? Check that:

 

  • The JAVA_HOME environment points to the JRE or JDK installation folder

  • The JAVA_HOME/bin folder has been added to the PATH environment variable

 

What is a Test Plan?

In your test plan, you should specify the overall settings and outline the steps that you want JMeter to execute while it runs. For your own reference, you can also name it and add comments.

 

Creating a Complete Test Plan

 

You Need To:
 

Set Up at Least One Thread Group and Sampler

A thread group is where you specify the number of users that you want to simulate. One thread = one user. By setting the ramp-up period, you can also tell JMeter how long it should take to reach all of the threads that you’ve chosen. You can also set the number of iterations for each user in the group with the Loop Count.
 

Set up Samplers

Samplers are super important as they perform the actual work in JMeter. JMeter executes the samplers and writes down the results, such as: start time, duration, success, response messages etc.  Listeners  can be used to view these results (but more about that in a bit). The HTTP Request, which lets you send a HTTP or HTTPS request to a web server, is the most commonly used sampler.

 

 

We Recommend That You:

 

Add Timers

Here you can set the duration of the delay from one request to the next (i.e. how many seconds you want JMeter to wait before navigating from the homepage to the features page).  

 

Add Configuration Elements

These allow you to manage elements, like the cache and the cookies, during  the test. We recommend adding the “HTTP Cache Manager” and the “HTTP Cookie Manager” to simulate a browser’s behavior. Find out more about making JMeter behave like a real browser in this article

 

 

Add Assertions

These let you define the pass or fail criteria for your test.


Let’s say you want to make sure your site or app responds within 100 milliseconds. You can set a Duration Assertion to specify that if any response lasts longer than 100 milliseconds,  the sample will be marked as “failed.”

 

The most important assertion to know is the Response Assertion. This covers 99% of your needs - so no wonder it’s so popular! You can use it to test the URL, response body, messages, embedded resources, redirects, headers and more. This assertion gives you loads of flexibility as it lets you test regular expressions rather than text patterns. JMeter handles regular expressions in a very similar way to Perl - except you don’t enclose the expression in //’s.

 

Find out more about commonly used assertions, what they do, and how to use them in our blog post: How to Use JMeter Assertions in Three Easy Steps.

 

Add Listeners

As I mentioned earlier, these let you view the results of a sampler. You can choose to view them in various formats, including a table, graph, tree, or log file. Listeners can be added anywhere in the test - but it’s important to know that they will only collect data from elements on the same level or below.

 

View Results Tree is the most commonly used listener as it presents all the test plan results in a user-friendly tree structure. Other listeners include the Assertion Results, Aggregate Report and Beanshell Listener.

 

One important thing to note: when you actually run the load tests, you should disable all your listeners as they use up a lot of memory. We’ll talk more about do’s and don’ts for running tests in the next blog post in this series.

 

How to Add Components to Your Test Plan

 

You can set up and add all of these components in the test plan before you run it. Here’s how:

  1. Right click on the name of your test plan

  2. Select ‘Add’

  3. Choose the component you want to set up and configure
     

 

Adding Thread Groups to a JMeter Test Plan

 

 

That’s it!


Check back next week for information on how to build test scripts, setup workflows, and run tests.

 

Need more JMeter training? Check out our free online course

 

If you have any questions or comments, please share in the comments box below.

 

How the BlazeMeter Load Testing Cloud Complements and Strengthens JMeter

 

While JMeter represents a strong and compelling way to perform load testing, of course, we recommend supplementing that tool with BlazeMeter, which lets you simulate up to millions of users in a single developer-friendly, self-service platform.  With BlazeMeter, you can test the performance of any mobile app, website, or API in under 10 minutes.  Here’s why we think the BlazeMeter/JMeter combination is attractive to developers:

  • Simple Scalability – It’s easy to create large-scale JMeter tests. You can run far larger loads far more easily with BlazeMeter than you could with an in-house lab.
  • Rapid-Start Deployment – BlazeMeter’s recorder helps you get started with JMeter right away, and BlazeMeter also provides complete tutorials and tips.
  • Web-Based Interactive Reports – You can easily share results across distributed teams and overcome the limitations of JMeter’s standalone UI.
  • Built-In Intelligence – BlazeMeter provides on-demand geographic distribution of load generation, including built-in CDN-aware testing.


To try out BlazeMeter, request a demo, or put your URL in the box below and your test will start in minutes.
 

 

     
arrow Please enter a valid URL

Interested in writing for our Blog? Send us a pitch!