Tips&Tricks: How to Mock GPS Locations of Your Android Devices?

Bitbar, the mobile devops company. Logo, large

In many cases, your top priority in mobile app testing is probably functional testing, compatibility testing and UI testing. To some mobile app developers, however, the major concern in app testing is to guarantee the top performance of their apps on mobile devices that are located in various countries. Today, we are going to walk you through how to mock the locations of devices within Testdroid Recorder.

As Testdroid Recorder is a Robotium-based test script generation tool,  you will find Class ExtSolo in our package com.bitbar.recorder.extensions. More information about ExtSolo functions and API can be found here:

https://github.com/bitbar/robotium-extensions

Below are the instructions of how to mock GPS locations of your devices by setting up parameters in test script.

setGPSMockLocation

public void setGPSMockLocation(double latitude, double longitude, double altitude)

Method used to simulate the desired localization.

Parameters:

latitude – latitude in degrees. (Positive number for North and negative for South)
longitude – longitude in degrees. (Positive number for East and negative for West)
altitude – altitude in meters

Example:

solo.setGPSMockLocation(37.42198, -122.085083, 40);

By the way – We’ll be rolling out these types of brief blogs with tips & tricks – and the best practices from our experts – for mobile app testing during the following autumn so please stay tuned and let us know if you want certain specific areas to be covered.

 

  • Gabbar Singh

    I am having trouble setting the GPS location. Can somebody help me in this regard?