Overview
In this blog, we are going to discuss a very powerful testing tool called JMeter. This tool has some exciting features, one being the ability to record HTTP requests/responses being sent/received from an Android/iOS device. So let’s get started!!!
Introduction of JMeter
JMeter is a Performance & Load testing tool for web application development has been done by Stefano Mazzocchi of Apache Software Foundation. Later it was redesigned to enhance the GUI and to add functional-testing capabilities.
Uses
It can be used to simulate a heavy load(by sending multiple requests) on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types. The results of the performance testing can be visualized in the form of graphs.
Pros
- Ability to load and performance test many different applications/server/protocol types (HTTP, FTP, SOAP etc.)
- Full Multithreading framework allows concurrent sampling by many threads and synchronous sampling of different functions by separate thread groups.
- And many more
Cons
- While simulating heavy load, it can consume a lot of memory
- It mainly works only for web applications
- Does not support JavaScript or Ajax
Download and install JMeter and its certificate on the Android/iOS device:
- Download Apache JMeter from Jmeter. (Download the zip file from the Binaries section)
- Extract the Zip file
- Send ApacheJMeterTemporaryRootCA.crt file present in the “bin” folder, to your Android or iOS device and install the Certificate.
(Refer to the below video for the step by step process.
Note: The process for the iOS device is similar to that of Android)
Run JMeter and Start recorder
To run JMeter, First, go to the bin directory of JMeter and:
For Windows: Double click on the jmeter.bat file then run the JMeter
For Mac:
- Open terminal
- Goto bin directory using the “cd” command (Example: $ cd /apache-jmeter-4.0/bin)
- Run JMeter using the command: $ sh jmeter.sh
This will open the GUI for JMeter
To add JMeter recording template:
- Go to File -> Templates…
- Select Recording option from the select template dropdown.
- Click on Create a button
- Click HTTP(S) Test Script Recorder (Check Port number as this will be used while setting up the proxy in the Android/iOS device)
- Click on the Start button that would start recording the HTTP requests
- On the Root CA certificate… popup, click OK button.
Set proxy in Android & iOS Device
Follow the below steps to set proxy in Android/iOS device
Note: Both the Android/iOS device and the device running JMeter should be on the same network.
For Android:
- Open WiFi settings
- Long press on connected WiFi
- Select Modify network option
- Click on the Advance option
- Select proxy type as Manual
- Enter the IP address of the device running JMeter in the Proxy Server field (To find the IP address – For Windows: Open cmd -> type IPCONFIG and press enter -> Select the IPv4 address. For MacOS: Open Terminal -> type IFCONFIG and press enter -> Select the inet address). Example – 192.168.0.1
- Enter Port number as in the recorder of the JMeter recording template. Example – 8888
For iOS
- Open Settings app
- Click on WiFi option
- Click on Create a button
- Click on Info button on connected WiFi
- Click on Configure Proxy option
- Select Manual option
- Enter the IP address of the device running JMeter in the Proxy Server field (To find the IP address – For Windows: Open cmd -> type IPCONFIG and press enter -> Select the IPv4 address. For MacOS: Open Terminal -> type IFCONFIG and press enter -> Select the inet address). Example – 192.168.0.1
- Enter Port number as in the recorder of the JMeter recording template. Example – 8888
- Click on the save button
(Refer to the below video for the step by step process)
Observing API Logs with an example
- Open application in the Android/iOS device
- Use any function in the application which might send a request to the server.
- Goto the View Results Tree listener in JMeter to view the logs. All API requests are recorded in JMeter. (refer to the screenshot below).
Read: Yudiz Solutions Ltd. Featured as a Development Leader on Clutch!