DEV Community

Gaurav Singh
Gaurav Singh

Posted on • Originally published at automationhacks.io on

Testing Android/IOS apps under network conditions

Photo by Leon Seibert on Unsplash

It’s 2020 and mobile phones are ubiquitous. Everyone has it and uses it constantly. Most of the time as testers, we test our mobile apps in office Wifi conditions with an ideal high-quality internet connection in terms of app performance.

However, we all know the real-life network is far from this ideal. We/our consumers mostly use our apps on the Go (traveling in a bus, sometimes even when walking) and the network conditions will rarely be the conditions that we test under.

In such cases, a carefully thought out and tailored UX can be the difference between a happy consumer who would like to use your app again Vs a frustrated or confused consumer who eventually uninstalls the app and move on to something else.

So hopefully, by now you must feel convinced that it is quite important to get feedback about the quality of your app under different network conditions.

However, since we can’t really travel to different parts of the office/home/city in search of such pockets of bad network areas every time we want to test right?

Luckily both Apple/Google gives us ways to simulate these network conditions. Let’s take a look at how:

Simulate network conditions on IOS

Apple provides a handy utility to help to simulate network conditions called network conditioner

Setup network conditioner

Connect your iPhone real device to your laptop via USB or start the simulator via Xcode

Open Windows > Devices and Simulator

Under Device conditions select Network Link

Once selected, You can choose a network in the range of Very poor to Edge, 2G, 3G, and what not. 🥳

Also, Once this setting has been set via Xcode, You can now access Developer section in your iPhone settings and enable as well as change these conditions easily

Remember to enable the network conditioner and then choose whichever condition you want to test on.
Enter fullscreen mode Exit fullscreen mode

Simulate network conditions on Android

On an emulator

If you are running an emulator image via android studio, then changing the network speed is as simple as going to Emulator settings > Cellular > Select Network Type > Select Signal Strength as per your test scenario requirement

You can also control this setting via adb by updating netdelay option of emulator utility with values like gprs, edge

~/Library/Android/sdk/emulator/emulator -avd <avd\_name> -netdelay none -netspeed full
Enter fullscreen mode Exit fullscreen mode

On a real device

If you real device has a SIM, then you can go into Network settings (Wifi & internet on Android 10) > SIM and network and then select the Preferred network type to either 2G, 3G or 4G

Another possible approach could be to use a proxy tool to throttle network calls by introducing some programmatic delays. Though not the most realistic way to set this up but nonetheless effective. More details on this in a future post.

Conclusion

Next time when you feel your app works perfectly under perfect network conditions, maybe try using one of these above to test the app under a less reliable network and see if the app still offers a graceful experience to the user.

If you found this useful, Do share it with a friend or colleague. Until next time, Happy testing.

Further read/References

In case you want to read a bit more about this topic, feel free to check out any of these excellent articles for more details.

Top comments (0)