10 Steps to Mobile App Performance Testing

As of 2021, the number of users of smartphones was 5.2 billion out of 7.8 billion people in the world. An affordable portable device with huge capabilities can turn into anything with apps designed to meet users’ needs. However, the quality, reliability and speed of the application must be the best in this highly competitive market.

Performance testing solutions are a way to identify opportunities and potentials of your product.In this article we will take a step-by-step look at how to write a load script for a mobile application and run a test by generating HTTP/HTTPS traffic on the app server. Our mobile app testing process will only take you 10 steps and two tools: use a free load testing tool Apache JMeter and an Android OS emulator.

Table of Contents

1. Choose operations and create a load profile

The first step to approach mobile app performance testing is to analyze the system and create a load profile. The choice of operations for the profile is made by processing the statistics for the most loaded month, selecting the peak day of that month by the number of operations and choosing the peak hour of that day. Pick the most intensive operations from the list for this hour. They should constitute more than 80% of the total load. The profile should also include the most resource-intensive operations and those that are important to the business, if any. The standard intensity of operations for our profile is taken from the statistics for the peak month, peak day and peak hour. It is also worth considering possible time limits for operations.

In case you do not have statistics on the operation of the application, e.g., because it is new, the profile is created on the basis of your expectations and forecasts.

Do you want to performance test your app?

There is no better place for a QA solution than Performance Lab.
Drop us a line to find out what our team can do for you.

2. Create a script in JMeter and configure an HTTP proxy server

As for the script, you’ll need Apache JMeter, a popular tool for load testing. You are probably already familiar with this software, but if you haven’t worked with it yet, it’s not a problem, either. It is easy to download and unpack. You also need to download and install JDK (Java Development Kit), a Java application developer suite, without which JMeter will not start. Both are top search results in Google. The JMeter shortcut is in the bin folder, it’s called jmeter.bat and is a Windows package file. At startup, a graphical user interface pops up. In JMeter you will actually work on your test plan.

Create a script in JMeter

There is the tree of your script on the left side of the interface, whilst information about the selected element from the left is displayed on the right side.

Now you can start creating your script.

1.  Add the main element for our future script. On the left, there is an element called Test Plan. For ease of understanding, think of it as your load scenario. The script can consist of one or more scripts, each of which performs a specific task.
Right-clickTest Plan -> Add -> Threads (Users) -> Thread Group, and add the main element. All elements from Threads (Users) are needed to configure the load delivery before starting the test. In particular, Thread Group is most often used for debugging, so at the moment you should be leaving it intact. It is important to understand that each script needs a separate “spool” of threads, as the intensity of these scripts can be different.

2. Right-click Test Plan -> Add -> Listener -> View Results Tree. This adds an element to view our future queries and responses, which is very useful when debugging our script.

3. Right-click on Thread Group -> Add -> Logic Controller -> Recording Controller to add an element inside your coil that allows to group the script on transaction writing automatically. This is quite convenient for a lot of actions.

4. Right-click on Test Plan -> Add -> Non-Test Elements -> HTTP(S) Test Script Recorder to add an element to record the script. Pay attention to the connection port: you can leave it 8888 by default, or you can change it to another free port. But make sure it matches the port you specify when setting up your mobile device.
In the Target Controller field, choose Test Plan > Thread Group > Recording Controller. This option indicates where the script will be recorded to.

Create a script in JMeter

If you click on the Start button before the script record starts, Jmeter will create a certificate or update the existing one. You’ll need the certificate later, so if you have just downloaded Jmeter, you should start recording, confirm the creation of the Root certificate in the pop-up window, or wait until it disappears, and stop the recording.

Create a script in JMeter

3. Install Android OS emulator, copy the certificate to your mobile device

At this stage it will be necessary to decide whether to use a real mobile device to write a script or to use a mobile operating system emulator. In this article we use Android MEmu emulator, which is very easy to install. We’ve also tried it with a real mobile device based on Android 10, and there is no difference, other than some visuals.

The next task is copying the Apache JMeter certificate to a smartphone/emulator. You will find it in the installation directory JMeter, in the bin folder. The file you’re looking for is called ApacheJMeterTemporaryRootCA.crt. It’s not a big deal to transfer files from a desktop to a smartphone, but copying a file to an emulator may look tricky, although it is easier.

Install Android OS emulator
Install Android OS emulator

On the right-hand side of the toolbar, you find the icon of the folder, and when you click it, you open the shared folder. The Windows icon will open a folder of your PC, where we copy your certificate to. The nearby Android icon will open a folder with our file on the emulator.

4. Configure the connection of the mobile device to the network

For further work it will be necessary to connect the desktop and smartphone/emulator to one local network. In the case of the emulator everything is simple, it is already on your PC, so we can safely consider this step implemented.

For a mobile device, it is not difficult to configure a connection with a desktop over a local network. Many people use wireless Internet on a smartphone every day using a router. The image below shows how the router connects the devices to one local network. It is enough to connect a mobile device (via Wi-Fi) and a PC (via LAN/Wi-Fi) to one router.

Configure the connection of the mobile device to the network

5. Download and install the app on your mobile device.

It’s time to download and install the mobile application you want to test on the emulator. On the right side of the toolbar, find the icon APK. It opens Explorer, where you find and select your application. We downloaded it directly from PlayStore, just to check if the script will be recorded correctly in this case.
Download and install the app on your mobile device
It is worth noting that if you want to download some client-server application and try to write a script, you will not be able to do it seamlessly. The reason is that nowadays it is almost impossible to find an application like this without a minimum degree of protection. In order to protect the application from incorrect data, hacking, theft of important information, stress load on the server, etc., developers add many checks into the code and implement SSL certificates. You won’t be able to get a response from the server via proxy. Of course, it is possible to bypass all this with the help of special utilities, but if you are a part of the team working on the project, you’d better ask developers to solve this problem.

Entrust mobile app performance testing to professionals.

Book a free online consultation with our experts.

6. Configure proxy on your mobile device

The next step involved in app testing is proxy configuration. It is needed to intercept mobile traffic while recording scripts from a mobile device and transferring it over a certain LAN port in Apache JMeter. You have already configured the proxy server on our desktop to receive traffic, and now you have to do the same on your emulator.

Configure proxy on your mobile device

1.  In the settings, find the list of wireless networks and choose the one you connected to.

2. Left-click this network and hold.

3. When a menu unfolds, select Modify Network.

4. Click the dropdown in advanced settings.

5. Proxy – Switch to Manual.

6. If you’re working on a PC, open the command line via Start -> Command Line or Start -> Execute ->, enter your command and press Enter.

7. In the console, write “ipconfig”, and then click Enter.

8. Copy a set of digits with dots from the line IPv4, and paste it into the field Proxy host name of our emulator.

9. In the Proxy Port field, enter the same port that you specified in the HTTP(S) Test Script Recorder settings in Apache JMeter setup.

10. In the Settings IP field, leave the DHCP value (on the real mobile device, if you do not have this option, select Dynamic).

11. Don’t forget to click Save.

7. Install a certificate on your mobile device

To install a downloaded certificate on a mobile device, it is sometimes not enough just to run it and install it through the certificate installer. The system will, of course, report that the certificate has been installed, but in fact it won’t seem to be there. Therefore, you need to install it through the settings. The actions described below are suitable for the emulator and may slightly differ on the smartphone.

1. Go to Settings -> Security -> Install from an SD card. it may be a little different in different devices, for example,

on ours it was Settings -> Security -> Additional settings -> Encryption and credentials -> Install from memory card.

2. Find your certificate.

3. Specify the name of the certificate.

4. Confirm certificate installation by clicking OK.

The system will ask for the screen lock password for security. Agree, and set up a password.

Install a certificate on your mobile device

8. Record mobile app performance testing script

Now you can start recording the script. Click Start in Jmeter and start the application in the emulator. If everything is set up in the right way, Recording Controller will add a transaction in which multiple requests will be grouped. Each next action in the application will add a transaction with its own queries until you click the Stop button in Jmeter. This way, you can record a script quite quickly.

Record mobile app performance testing script

You can save it, too:

File -> Save Test Plan as, or open it:

File -> Open.

All Test Plan elements can be moved with the mouse, or commented on with Ctrl+T. You can hide or show the contents of the element, copy and paste with standard combinations, and delete with the Delete button. It is also possible to copy a script to another scenario by opening two windows of the tool, which is useful when designing a large scenario.

9. Disable proxy on your mobile device

When recording is on, the traffic is sent to Apache JMeter, but after the script is recorded, you won’t have access to the Internet via Wi-Fi. To restore connection to Wi-Fi, you have to disable the proxy server.

1. Go to the settings and find the network you are connected to in the list of available networks. Click on it, and the list of networks will unfold.

2. Left-click and hold the name of your network.

3. When a menu unfolds, select Modify Network.

4. Change Proxy to None.

5. Click Save.

Disable proxy on your mobile device

On a smartphone, the roadmap is similar. If you are recording a lot of scripts, you can switch from Wi-Fi to Mobile Data and back. The proxy settings on Wi-Fi do not reset, so you can quickly start writing another script.

10. Process the script and start the test

This stage is no different from the processing of a regular script. After parameterizing, correlating and adding test data, a debugging test (one iteration with one virtual user) is run to check for errors. You can see the results of the script debugging by selecting the View Results Tree element from the script tree. In order to get as close as possible to the real conditions, you may want to insert delays between actions.

 

To smooth the load,use Ultimate Thread Group or the Stepping Thread Group. You’ll find it in

Test Plan -> Add -> Threads (Users).

If an element you need is missing, you can add it using Options -> Plugins Manager.

It is also necessary to calculate the pacing of each operation, the number of virtual users used, the number and duration of load stages. An important step is to add monitoring elements through

Test Plan -> Add -> Listener, such as Transactions per Second,  Active Threads Over Time, Hits per Second, Aggregate Report, etc.

These tools will help you collect data for further analysis. After all these actions you can start the test.

Conclusions

In this article we figured out how to configure mobile application traffic reading, record scripts and run tests. Depending on the test objectives, you may need to conduct a series of launches. If for some reason you have failed to run the test or get the results, you can contact us, our company is engaged in all kinds of performance testing.

Have a project in mind?

There is no better place for a QA solution than Performance Lab.
Drop us a line to find out what our team can do for you.

Latest posts from us

Top 5 best online testing tools preview
Top 13 Best Online Load Testing Tools
Why is performance testing before Black Friday a must
Why is performance testing before Black Friday a must?
Project management in performance and load testing projects
Project management in performance and load testing projects
Test environment in the project lifecycle
Testing environment in the project lifecycle
10 Steps to Mobile App Performance Testing preview
10 Steps to Mobile App Performance Testing​