jMeter - Web Test Plan
Let's build a simple test plan which tests a web page. We will write a test plan in Apache JMeter so that we can test performance of one web page say page shown by the URL:http://www.tutorialspoint.com/.
Open the JMeter window by clicking on /home/manisha/apache-jmeter-2.9/bin/jmeter.sh. The JMeter window will appear as below:This is a JMeter window having nothing added yet. Details of the above window are:
Test Plan node is where the real test plan is kept.
Workbench node is where the temporary stuff is kept.
Rename Test Plan
Change the name of test plan node to Sample Test in the Name text box. You have to change focus to workbench node and back to Test Plan node to see the name getting reflected.
Add Thread Group
Now we will add our first element in the window. We will add one Thread Group, which is placeholder for all other elements like Samplers, Controllers, Listeners. We need one so we can configure number of users to simulate.
In JMeter all the node elements are added by using the context menu. You have to right click the element where you want to add a child element node. Then choose the appropriate option to add.
Right click on Sample Test(our Test Plan )> Add> Threads(Users)> Thread Group. Thread Group will get added under the Test Plan (Sample Test) node.
We will name Thread Group as Users. For us this element means Users visiting the TutorialsPoint Home Page.
Now we have to add one Sampler in our Thread Group (Users). As done earlier for adding Thread group, this time we will open the context menu of the Thread Group (Users) node by right clicking and we will add HTTP Request Sampler by choosing Add > Sampler> HTTP request option.
This will add one empty HTTP Request Sampler under the Thread Group (Users) node. Let us configure this node element:
Name: We will change the name to reflect the action what we want to achieve. We will name it as Visit TutorialsPoint Home Page
Server Name or IP: Here we have to type the web server name. In our case it is www.tutorialspoint.com. (http:// part is not written this is only the name of the server or its IP)
Protocol: We will keep this blank, which means we want HTTP as the protocol.
Path: We will type path as / (slash). This means we want the root page of the server.
We will add a listener. Let us add View Results Tree Listener under the Thread Group (User) node. This will ensure that the results of the Sampler will be available to view in this Listener node element. Open the context menu and Right click on Thread Group(Users) choose Add > Listener > View Results Tree option to add the listener.
Run the Test Plan
Now with all the setup, let's execute the test plan. With the configuration of the Thread Group (Users) we have kept it all default values. This means JMeter will execute the sampler only once. It will be like a single user and only one time.
This is similar to like a user visiting a web page through browser, only here we are doing that through JMeter sampler. We will execute the test plan using Run > Start option.
Apache JMeter asks us to save the test plan in a disk file before actually starting the test. This is important if we want to run the test plan again and again. If we say not to save by clicking No option it will run without saving.
We have kept the setting of the thread group as single thread (that means one user only) and loop for 1 time (that means run only one time), hence we will get result of one single transaction in the View Result Tree Listener.
Details of the above result are:
Green color against the name Visit TutorialsPoint Home Page indicates success.
JMeter has stored all the headers and the response sent by the web server and ready to show us the result in many ways.
The first tab is Sampler Results. It shows JMeter data as well as data returned by the web server.
The second tab is Request, where all the data which was sent to the web server as part of the request is shown.
The last tab is Response data. In this tab the listener shows the data received from server as it is in text format.
This is just a simple test plan which executes only one request. But JMeter's real strength is in sending the same request like many users are sending it. To test the web servers with multiple users we will have to change the Thread Group (Users) settings.