Testing

Our Mobile SDKs make it easy not just to build but to test location features in your apps as well. This doc covers various such APIs available in the SDKs and talks about how they can be used for testing purposes.

SDK Debug Logging

HyperTrack SDKs have console logging DISABLED by default for all Log Levels except for ERROR and WARNING.

To enable VERBOSE SDK logging, call HyperTrack.enableDebugLogging(int) API with Log.VERBOSE as parameter.

// Specify Log level as parameter to enable logs upto that level
HyperTrack.enableDebugLogging(Log.VERBOSE);
// This API is not available for iOS SDK (Swift) yet.
// We're working on adding this API and will update soon.
// This API is not available for iOS SDK (Obj-C) yet.
// We're working on adding this API and will update soon.

Using Mock Location Apps

HyperTrack SDKs rejects Mock Locations on the device by default. In essence, mock location apps provide a continuous stream of locations (latlongs) and the SDK generates location data accompanied with activity & device health data. This makes mock location apps insufficient for testing the full power of HyperTrack features. Read more about it in depth in our blog on Detecting mock locations on Android.

We recommend using HyperTrack Mock APIs for your testing but if you want to test using Mock location apps, call HyperTrack.enableMockLocations(boolean) API to enable mock locations on the sdk.

// Call this API to enable mock locations in the sdk. 
// With this the SDK will start accepting all mock locations.
HyperTrack.enableMockLocations(true);
// This API is not required for iOS.
// This API is not required for iOS.

Mocking User's tracking session

A user’s tracking session starts with HyperTrack.startTracking() and ends with HyperTrack.stopTracking(). In order to mock user movement developers would call HyperTrack.startMockTracking(callback) and HyperTrack.stopMockTracking() respectively.

[info] How it works?

HyperTrack.startMockTracking() API starts a simulation from the device's current location to a nearby place of interest within a 5-10km radius so the session is long enough to test your app & its features.

// Replace startTracking API with startMockTracking
// HyperTrack.startTracking();
HyperTrack.startMockTracking(new HyperTrackCallback() {
    @Override
    public void onSuccess(@NonNull SuccessResponse response) {
        // Handle startMockTracking success here
    }

    @Override
    public void onError(@NonNull ErrorResponse errorResponse) {
        // Handle startMockTracking error here
        Toast.makeText(MainActivity.this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
    }
});

// Replace stopTracking API with stopMockTracking
// HyperTrack.stopTracking();
HyperTrack.stopMockTracking();
// Replace startTracking API with startMockTracking
// [HyperTrack startTracking];
[HyperTrack startMockTracking];

// Replace stopTracking API with stopMockTracking
// [HyperTrack stopTracking];
[HyperTrack stopMockTracking];
// Replace startTracking API with startMockTracking
// [HyperTrack startTracking];
[HyperTrack startMockTracking];

// Replace stopTracking API with stopMockTracking
// [HyperTrack stopTracking];
[HyperTrack stopMockTracking];

[warning] Call stopMockTracking

Once the simulation is over or your testing is done, remember to call HyperTrack.stopMockTracking() API to stop user's mocked session.

results matching ""

    No results matching ""