2019 / 8 / 12
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.
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:
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.
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.
Configure the 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.
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.
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.
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.
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.
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.
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).
What the output exactly means:
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.