JMeter
What is perfomance test?
A non-functional software testing technique that determines how the speed, response time, stability, reliability and scalability of an application holds up under a given workload.
Why do we need perfomance test?
At least one of the following reasons:
- To determine whether the application satisfies performance requirements (for instance, the system should handle up to 1,000 concurrent users).
- To locate computing bottlenecks within an application.
- A bottleneck is a point of congestion in a production system that stops or severely slows the system.
- To establish whether the performance levels claimed by a software vendor are indeed true.
- To compare two or more systems and identify the one that performs best.
- To measure stability under peak traffic events.
Installation
- JMeter requires Java JDK 8+ to run.
- Note: Java JDK releases a new version every 6 months and releases a LTS every 2 years
- The latest LTS version is Java JDK 21 (shows below), but you can also use any other 8+ version.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Java JDK Download Page
- Here I choose the .exe file to download, but you can choose what format you prefer.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Open the installation file, just use default settings, don't have to change anything, click next, next, then close when finish.
- For Windows system, click the words with the red circle shown in the screenshot below, to download JMeter zip file.
- JMeter Download Page
- Don't download it from the source section, otherwise you will miss a file called ApacheJMeter to run JMeter.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Unzip the downloaded file, execute jmeter.bat in the \bin directory, and open the JMeter software, it might take a few seconds.
- YES!! YOU DON'T HAVE TO INSTALL JMETER, JUST UNZIP AND EXECUTE IT.
- Be careful! It has lots of twins also named jmeter, please check the file format.
- Don't close the terminal window.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Use JMeter to create a test plan.
- When you open JMeter, you will see Test Plan here.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Right clik on Test Plan -> Add -> Threads (Users) -> Thread Group
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Fill in the information. We just need a name for now.
- We simulate only 1 thread because it's other people's server, that's why we don't modify other information here.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Now we configure the settings.
- Setup HTTP default request HEADER
- Right click on the thread group, here my thread group name is reqres.in_APIs_testing, Add -> Config Element -> HTTP Request Defaults
- HTTP Request Defaults is the default setting for every HTTP Request under this thread group.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Fill in the information.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- We will send JSON in the request body for POST APIs later, so we add HTTP Header Manager, to add Content-Type: application/json in the request header
- Content-Type: application/json indicates that the request body format will be JSON.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Now let’s add the APIs that we are going to test.
- All the APIs we use are from https://reqres.in/
- Right click on the thread group, here my thread group name is reqres.in_APIs_testing, Add -> Sampler -> HTTP Request
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Fill in the information
- Let's try register together.
-
- Name
-
- Method and path
- Register and login are 99.9% POST method.
- Of course, check API document from your project.
-
- Register data
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Let's try login together.
-
- Name
-
- Method and path
-
- Login data
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Same work for other APIs.
- Why we don't have to fill in protocol and server name/IP?
Because we already did that in HTTP Request Defaults.
- Get method normally passes API parameters in the url, not in the HTTP request body.
- Get a list of users
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Get a single-user
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Get another single-user
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Delay response example API
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
How to see the result and generate a report?
- Commonly we add View Results Tree and Summary Report to observe the result
- Right click on the thread group, here my thread group name is reqres.in_APIs_testing, Add -> Listener -> View Results Tree
- Right click on the thread group, here my thread group name is reqres.in_APIs_testing, Add -> Listener -> Summary Report
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- The first time when you want to execute the test flow, but haven't saved the file, JMeter will notify you.
- Then we click the green triangle button to execute the test flow.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Result Tree page
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Summary Report
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- You can also right-click and click on clear to clear the result.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Want a more beautiful report?
- After running the test, and having the result values.
- Click on the Summary Report on the left.
- Click on the Save Table Data on the bottom.
- Then we can use the .csv file that we have just saved for our HTML report. 🥳
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Tools -> Generate HTML report
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Fill in all fields.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- Remember, in the 3rd step, the folder should be empty.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- After filling in all the fields, click on the Generate report button.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- You will have the report like this, just open the index.html file in the output directory.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Go further
- In real life, we might also want to
- Simulate more users, you can modify the Number of Threads (users)
- Have all the threads running not all at the beginning, but gradually, you can modify Ramp-up period (seconds), it means it will reach the number of threads at this time.
- If you want to run the whole plan more than 1 time, you can modify Loop Count.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- You might want to perform "login" with many users using their usernames and passwords, you can save the information in .csv file, and insert the file to JMeter.
- And of course, you can edit the script in JMeter to save their tokens, and use it in the following APIs which need auth.
- The last but not the least.
- If we aim to test max 10000 users, we will schedule our testing plan to test different amount of the numbers, for example, test 1000 ppl, 3000 ppl, 5000 ppl, 8000 ppl, and finally 10000 ppl.
- And We can analyse the result, to locate computing bottlenecks within an application.