How to test mobile app performance using JMeter?

Any mobile application performance can be determined based on the request/response processed in between the client and server. This is the post applicable for the mobile application interacting with the web server through HTTPS web request mode of communication.

JMeter can be used to measure the performance of the mobile application in which it will records the request through proxy. Proxy can be configured in iPhone or Android device and the request will be captured by using JMeter for further analysis. It can be used to achieve Man In The Middle (MITM) Attack under security testing perspective of capturing & modifying the data packets of both request & response but in this post, we are going to see only performance strategy.

Pre-requisites:

  1. JDK 1.8 should be installed in the target laptop with Windows/Linux/OS X
  2. Latest Apache JMeter should be downloaded using the below URL;

https://jmeter.apache.org/download_jmeter.cgi

  1. Both target devices such as iPhone or Android and laptop should be paired in the same Wi-Fi network

Please note, this is the post tried in Windows 10 OS paired with Wi-Fi router under 2.4Ghz and Motorola G5 Plus with Android OS 8.1 used. We are going to capture all the request triggered in any Native, Hybrid and Mobile Web (Chrome) mobile application and the response received from the web server. 

Steps to configure JMeter:

  1. Extract the downloaded Apache JMeter setup files
  2. Go to the bin location of Apache JMeter setup in command prompt and run the jemeter.bat as mentioned below;

1_jm

  1. Add ‘Thread Group’ after right click the ‘Test Plan’ as mentioned below;

2_jm

  1. Add ‘Recording Controller’ after right click the ‘Thread Group’ as mentioned below;

3_jm

  1. Add ‘View Results in Table’ after right click the ‘Thread Group’ as Listener as mentioned below;

4_jm

  1. Add ‘HTTP(S) Test Script Recorder’ after right click the ‘Test Plan’ as mentioned below;

5_jm

  1. You can able to see ‘Start’ button in ‘HTTP(S) Test Script Recorder’ and ensure the port number, which should be used to configure in the mobile devices;

6_jm

  1. Click ‘Start’ button in ‘HTTP(S) Test Script Recorder’ window and you can see certificate file will be auto-generated under the bin folder of Apache JMeter setup;

7_jm

  1. Ensure certificate file ‘ApacheJMeterTemporaryRootCA.crt’ is available in the bin folder location of Apache JMeter setup
  2. Click ‘Stop’ button in ‘HTTP(S) Test Script Recorder’ window and you need to copy the certificate file in mobile devices running with Android OS and iOS

Please note, if the firewall blocking you to utilise the default port available in ‘HTTP(S) Test Script Recorder’ then please follow the below steps to run the JMeter in laptop;

jmeter.bat -H my.proxy.server -P 8091 -u username -a password -N localhost

Steps to Configure Proxy in Android Device;

  1. Copy the certificate file ‘ApacheJMeterTemporaryRootCA.crt’ from bin folder to mobile phone storage location either internal storage or SD Card
  2. Install the certificate based on the below steps;

2.1 Go to Wi-Fi Settings

2.2 Go to Wi-Fi Preferences

2.3 Select Advanced options

2.4 Select Install Certificates

2.5 Select the Menu and Go to Certificate available location in phone storage

2.6 Select the Certificate file and device prompt you to enter the device PIN or        fingerprint

2.7 Enter the Certificate name as ‘ApacheJMeter’ (Any name you can give)

2.8 You could see the Certificate successfully installed toast message in the phone screen

  1. Turn Wi-Fi toggle OFF and make it ON again
  2. You could see your Wi-Fi end point which was already configured and long press your end point name
  3. Select Modify network (Please note options will vary for each device OEM’s)
  4. Select Advanced options
  5. Select Proxy options as Manual
  6. Enter your laptop IP Address (IPv4 Address) under Proxy hostname textbox and you can get your laptop system IP Address by running the ‘ipconfig’ command in the command prompt; Refer the IP Address available under the ‘Wireless LAN adapter WiFi:’ section as mentioned below;

8_jm

  1. Enter the port number ‘8888’ as you noted in the ‘HTTP(S) Test Script Recorder’ window available in JMeter
  2. Select DHCP option under IP Settings
  3. Click Save button
  4. Ensure Wi-Fi connected in the Wi-Fi settings

Data (Request) Analysis in JMeter through Wi-Fi network:

  1. Go to JMeter
  2. Click ‘Start’ button in the ‘HTTP(S) Test Script Recorder’ window
  3. Open the Target mobile application installed in the Android device and I’ve used ‘Fontli’ Native mobile application to analyse the performance
  4. Login the application with username and password (Please note, you cannot access internet if the ‘HTTP(S) Test Script Recorder’ is not started in JMeter)
  5. User credentials will be validated in the server and upon successful validation, home screen has been displayed in the application
  6. Logout from the application
  7. Click ‘Stop’ button in the ‘HTTP(S) Test Script Recorder’ window in JMeter
  8. Expand the ‘Recording Controller’ and you could see all the request and response associated with the mobile application used in the Android device

9_jm

  1. Select the View Results in Table in JMeter
  2. Save the created Test Plan; Run the recorded script as mentioned below and see the performance of each triggered request and the received response

10_jm

  1. You could see the performance results in View Results in Table window and you could see signin API alone of the target application is taking 1338 milli seconds and signout API is taking 2966 milli seconds based on the below test results;

11_jm

Thank you!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s