Overview
The Apache JMeter is a pure java open source testing software. Firstly, JMeter was developed by Stefano Mazzocchi of the Apache Software Foundation. It is freely available as it is open source. JMeter was designed to do the Performance & Load Testing. It also covers functional & regression testing. JMeter is used for testing the Web Application or FTP Application. JMeter is used for database testing purpose nowadays. JMeter can be used to analyze & measure the performance of Web Application.
For Installation Purpose, it requires JDK 5 or higher. Compatible of running on any environment/workstation that accept JVM (Java Virtual Machine).
Working of JMeter
JMeter merge/combines a group of users that are sending the requests to the destination/target server and returns the results that shows the Performance of the target server/application. Results will be displayed in the form of Charts, Tables, Graphs, Trees or in the form of Log File.
Following Figure will help you to understand the working of JMeter easily.
Few Elements of JMeter are discussed below
1.Thread Group
Collection of Threads is known as Thread Group. Each Thread represents a single user using the application under test.
If you set the number of threads as 1000.JMeter will create and combine 1000 user requests to the server under test.
2 Samplers
As we know that JMeter supports testing HTTP, HTTPS, FTP & many other protocols.
Thread Group simulate user requests to the server. The requests can be HTTP Request, FTP Request or JDBC Request etc. That is Samplers.
3. Listeners
Listeners displays the results of the execution of test. They display results in the form of Graphs, Trees, Tables as well in Log File.
4. Configuration Elements
CSV DataSet Config
For example, if you want to test a website for 1000 user’s login with different credentials then no need to record the scripts 1000 times. Username & Password will be stored in a text file. JMeter has an element that allows to read the username & password from that text file. It is CSV DataSet Config.
Login Config Element
It is used to simulate single user login. It is suitable for login parameter only.
Performance Testing using JMeter
Step 1: Insert Thread Group
- Run JMeter & Select the existing Test Plan.
- Then, Insert the Thread Group.
- Right Click on Test Plan & Insert a new Thread Group: Add -> Thread(Users) -> Thread Group.
Now, Enter Thread Properties in Thread Group as below.
Number of Threads- 1000 i.e. 1000 users are connected to the destination website.
Ramp Up Period- Time Delay before starting another user. 1000 users/1000 seconds thus the delay between each user will be 1 sec.
Loop Count- 10 i.e. Single user is connecting the website 10 times.
Step 2: Insert JMeter Elements
Right Click on Thread Group:
Add -> Config Element -> HTTP Request Defaults
Enter target server in server name or IP as HTTP runs on 80 port number thus enter 80 as given below.
Right Click on Thread Group: Add -> Sampler -> HTTP Request.
Example: If you enter calendar in Path Field, It will send URL request http://www.google.com/calendar to the Google Server.
If you put the path field blank, Apache JMeter will send the URL request http://www.google.com to the Google Server.
Here, I will put it blank.
Step 3: Insert Listener for viewing the results.
Add -> Listener -> Graph Results
You can view the results in the form of Graph, Table, Tree etc. Here I have selected Graph.
Step 4: Finally, Execute the Test & get the result
Click on Run & result will be displayed.
Throughput should be more & Deviation should be less which shows good performance. Server Performance is said to be good if Throughput is more & Deviation is less.
Database Testing using JMeter
Step 1: Insert Thread Group
- Run JMeter & Select the existing Test Plan.
- Then, Insert the Thread Group. Right Click on Test Plan & Insert a new Thread Group:
Add -> Thread(Users) -> Thread Group.
Step 2: Insert JDBC Connection Configuration
- Right click on Thread Group.
- Then, Add -> Config Element -> JDBC Connection Configuration
Now, Add the Details in Database URL as jdbc:mysql://localhost:3306/registration_table where 3306 is port number, registration_table is my database. Add com.mysql.jdbc.Driver in JDBC Driver Class & Add root in Username.
Step 3: Insert JDBC Request.
- Right Click on Thread Group.
- Then, Add -> Sampler -> JDBC Request
Now, you can select any query type. Here, I am selecting Select Statement. Now, enter “select * from customer” where customer is my Table Name in registration_table Database.
Step 4: Insert Listeners for viewing the result
In this, I will add 2 Listeners such as View Results in Table, View Results Tree.
- Right Click on Thread Group.
- Add -> Listener -> View Results Tree.
- Again, Add -> Listener -> View Results in Table.
Step 5: Run JMeter
It will display the results in form of table as well as in tree.