In JMeter a test plan describes a series of steps it will execute. A complete test plan will consist of one or more Thread Groups, logic
controllers, sample generating controllers, listeners, timers, assertions, and configuration elements.
In this section, you will learn how to create a basic Test Plan to test a web site.
To add this element:
Select the Thread Group element in the tree to see the Thread Group Control Panel in the right section of the JMeter window as shown in fig below.
Next, you need to modify the default properties. The various characteristics of the threads (users) can be defined in thread group section as:
In our tutorial, increase the number of users to 5. In the Ramp-Up Period, leave the the default value of 1 seconds. This property tells JMeter how long to delay between starting each user. For example, if you enter a Ramp-Up Period of 5 seconds, JMeter will finish starting all of your users by the end of the 5 seconds. So, if we have 5 users and a 5 second Ramp-Up Period, then the delay between starting users would be 1 second (5 users / 5 seconds = 1 user per second). If you set the value to 0, then JMeter will immediately start all of your users. Finally enter a value of 2 in the Loop Count field. This property tells JMeter how many times to repeat your test. If you enter a loop count value of 1, then JMeter will run your test only once. To have JMeter repeatedly run your Test Plan, select the Forever checkbox.
Thus, 5 users ramping up one by one in an interval of 1 second each and repeat the request for 2 times.
So totally 5 x 1 x 2 = 10 users as a whole.
Right-click on ThreadGroup element > Add > Config Element > HTTP Request Defaults.
The name of web site or web application that you want to test is to be inputted into the Server Name or IP field and leave the remaining fields with their default values. For the test plan you are building if we specify domain name as www.javakart.com then all HTTP requests will be sent to the same web server, www.javakart.com. Select this element to view its control panel as shown in fig.
HTTP Request-1
Add first HTTP Request to JMeter Users (Thread Group) element as:
Go to Add > Sampler > HTTP Request.
After adding HTTP Request element select it and edit the following properties.
HTTP Request-2
Add second HTTP Request to JMeter Users (Thread Group) element. After adding HTTP Request element select it and edit the following properties.
Select JMeter ThreadGroup element and add a listener as:
After adding listener we need to specify a directory and file name of the output file. Now everything is done to run to a simple web test plan using JMeter.
In this section, you will learn how to create a basic Test Plan to test a web site.
Add Thread Group Element (Adding Users)
Adding Thread Group element is the first step you want to do with every JMeter Test Plan. The Thread Group tells JMeter the number of users you want to simulate, how often the users should send requests, and the how many requests they should send.To add this element:
- Open GUI mode of JMeter.
- Select Test Plan and Right-Click on it to get Add menu.
- Then select Add > Threads (Users) > ThreadGroup.
Select the Thread Group element in the tree to see the Thread Group Control Panel in the right section of the JMeter window as shown in fig below.
Thread Group with Default Values |
Next, you need to modify the default properties. The various characteristics of the threads (users) can be defined in thread group section as:
- Numbers of Threads (users)
- Ramp-up Period (when to send request), and
- Loop Count (how many times to repeat the request)
Load = [ Number of Users ] x [ Ramp Up in Seconds ] x [ Loop Count ]
In our tutorial, increase the number of users to 5. In the Ramp-Up Period, leave the the default value of 1 seconds. This property tells JMeter how long to delay between starting each user. For example, if you enter a Ramp-Up Period of 5 seconds, JMeter will finish starting all of your users by the end of the 5 seconds. So, if we have 5 users and a 5 second Ramp-Up Period, then the delay between starting users would be 1 second (5 users / 5 seconds = 1 user per second). If you set the value to 0, then JMeter will immediately start all of your users. Finally enter a value of 2 in the Loop Count field. This property tells JMeter how many times to repeat your test. If you enter a loop count value of 1, then JMeter will run your test only once. To have JMeter repeatedly run your Test Plan, select the Forever checkbox.
Thus, 5 users ramping up one by one in an interval of 1 second each and repeat the request for 2 times.
So totally 5 x 1 x 2 = 10 users as a whole.
Add HTTP Request Defaults
Adding HTTP Request Defaults is nothing but defining the tasks that users will be performing. This element does not tell JMeter to send an HTTP request. It simply defines the default values that the HTTP Request elements use. We can add this element as:Right-click on ThreadGroup element > Add > Config Element > HTTP Request Defaults.
The name of web site or web application that you want to test is to be inputted into the Server Name or IP field and leave the remaining fields with their default values. For the test plan you are building if we specify domain name as www.javakart.com then all HTTP requests will be sent to the same web server, www.javakart.com. Select this element to view its control panel as shown in fig.
HTTP Defaults for Test Plan |
Adding HTTP Requests
The number of web pages to be tested, the number of HTTP requests should be created.Consider in our test plan we will make two HTTP requests to test two web pages. The first one is for javakart's home page (www.javakart.com/) and second one is for javakart's contact page (www.javakart.com/contact).HTTP Request-1
Add first HTTP Request to JMeter Users (Thread Group) element as:
Go to Add > Sampler > HTTP Request.
After adding HTTP Request element select it and edit the following properties.
- Change the name of HTTP Request as 'Home Page'
- Set the path filed to ' / '
HTTP Request for www.javakart.com Home Page
HTTP Request-2
Add second HTTP Request to JMeter Users (Thread Group) element. After adding HTTP Request element select it and edit the following properties.
- Change the name of HTTP Request as 'Contact Page'.
- Set the path filed to '/Contact'
HTTP Request for www.javakart.com Contact Page
Add a Listener to View Test Results
A Listener, is a final element we need to add to our Test Plan that is responsible for storing all of our HTTP Requests in a file and presenting a Visual Model of data.Select JMeter ThreadGroup element and add a listener as:
Add > Listener > Graph Results
After adding listener we need to specify a directory and file name of the output file. Now everything is done to run to a simple web test plan using JMeter.