Getting started with Jmeter : Part 2

Getting started with Jmeter : Part 2

2019 / 8 / 12

Load Testing, Performance Testing, Best Practices

Test Plan Components and Running a Test Script.


JMeter is a very popular Load Testing and Performance Testing tool. JMeter is an Open Source Software and 100% Java Application, it is designed to stimulate browser’s like behavior by sending requests to web or application server just like a browser will do.

After such a detailed discussion on How to install JMeter. I hope everyone is having a running setup of JMeter. This blog post is a tutorial for beginners for getting started with JMeter. Please refer to the previous blog post Getting Started with JMeter: Part 1 Installation and Executing JMeter in different Modes for the detailed steps on installing JMeter.

Now it’s time to get started with the actual working of JMeter. For this, we need to Understand a simple term first Test Plan. Test Plan is just a JMeter Script specifying overall settings and steps that JMeter need to execute when it runs.

Creating a Complete Test Plan

For the beginners let’s keep things straight and start with a basic example of a Test Plan which tests a web page. We will be using our company’s website www.frugaltesting.com.

Follow the steps below for creating a Test Plan.

1. Start JMeter

In this example, we will start JMeter in GUI Mode by running the jmeter.bat file located in the /bin directory. JMeter Interface will look like this:

JMeter Start screen

2. Rename the Test Plan

Change the name of Test Plan to SampleTestPlan in the Test Plan node. Change the focus from Test Plan node to Workbench node to get the change reflected.

JMeter Test Plan Name

3. Add a Thread Group

To configure a Test Script, the first step is to add a Thread Group. It acts as a placeholder for all other elements like Sampler, Listener and Controllers.

Each Thread Group represents a User where Thread Group stimulate how users behave on an app.

In JMeter, all nodes are added using the Context Menu:
    1. Right-click on the Node for which you want to add a child element.
    2. Choose the appropriate element to add.
    3. To add Thread Group, Right Click on the SampleTestPlan →Add→Thread(Users)→Thread Group.

JMeter Thread Group

Configure the Thread Group:

  • Name: Can be anything. Here we have set it to Users.
  • Number of Threads: This means the number of Users we want to stimulate. In this example, we are keeping it to the default value 1.
  • Ramp-up Time: How much time to allow a Thread Group to go from one user to another. In this example, as only 1 thread is there, we are setting it to the default value.
  • Loop Count: This means how many times the test should be looped.

JMeter Configure Thread Group

4. Add Sampler

We need to send HTTP Request to the web page, for this we need to add a Sampler. Here we are adding HTTP Request type of Sampler. There are 20 types of Sampler available.

JMeter Sampler

For adding a Sampler, Right Click on Thread Group (Users) added in the previous step→Add→Sampler→HTTP Request.

Configure the Sampler:

  • Name: Set up a name for Sampler. For this example, we have named it ViewFrugalTesting.

  • Server or IP: Mention the server or IP that you intend to test. For this case it is www.frugaltesting.com. https:// or http:// will not be part of this field.

  • Protocol: We will let this be a default value (HTTP) by keeping it blank.

  • Path: We type slash(/) in the Path field. This means we want to query the root or we can say the main page.

JMeter Configure Sampler

5. Add Timers

Whenever we open a website, there are always naturally some sort of delays and pauses. These delays and pauses can be stimulated with the help of Timers.

Constant Timers are the most common, though there are 8 types of timers available.

To add a Timer Right-click on the Sampler→ Add→ Timer→ Constant Timer.

JMeter Timers

In this case, we are keeping 300 milliseconds.

6. Add Listener

One of the most important steps in test plan executing is logging and debugging the results. Obviously, we want to see the results. This is possible with the help of Listeners.

View Result Tree is the most common type of Listener. There are 16 types of different Listeners that are available.

To add a Listener Right Click on Thread Group(Users)→Add→Listener→View Result Tree.

JMeter Listners

Now click on the save option and your Test Plan will be saved as a .jmx file.

7. Run the Test Plan

With all the configuration done, Let’s run the Test Plan. Since we have kept the default values for the Thread Group, it means it will stimulating as a single user.

To execute the Test Plan, all you need to do is just select the Run option from the menu and then select the Start option.

JMeter Run Test Plan

NOTE: Even if you forget to save the file after finishing the setup or in the beginning, when you try to execute the file it will automatically prompt you to save the file.

JMeter Save Test Plan

Click on the Yes option and you are ready to save and execute the Test Plan. You can also opt not to save the file and execute(without saving).

8. View the Output

To view the output of the Test Plan run use View Results Tree (which we already added).

JMeter Output View

What the output exactly means:

  • The success of the Test Plan is marked by the green color shield symbol next to the name ViewFrugalTesting.
  • There are 3 headers in the result section- Sampler result, Request and Response Data.
  • Sampler results show 2 types of data- JMeter Data and the Data returned by the webserver.

JMeter Output

  • Request tab shows the data sent as a part of request to the webserver.

JMeter Request Tab

JMeter Request Tab

  • Response tab shows the data retur ned by a web server in the form of text.

JMeter Response Tab

JMeter Response Tab

Now Finally we are capable of running a simple and basic Test Script in JMeter. We are also able to analyze the results.

Keep practicing, we will be back with a list of Top 10 Plugins in JMeter as per Usage Statistics.

You might also like