App launch parameters

Overview

Launch parameters allow your app to execute specified actions upon launch, guided by the data received. They are crucial in testing scenarios to simulate different user journeys and validate that the app behaves as expected. In the context of automated E2E testing with our services, you can efficiently retrieve and utilize these parameters to streamline your testing workflows.

For convenience, we set the key "isGptDriver": true while running your app on our platform to allow you to easily detect if your app is running in GPT Driver.

Retrieve data

Swift: Retrieving Data with UserDefaults

The data passed will be stored in the shared defaults object, accessible by calling the appropriate method (based on type) e.g.

Swift

UserDefaults.standard.bool(forKey: "isGptDriver")
UserDefaults.standard.object(forKey: "objectKey")
UserDefaults.standard.string(forKey: "stringKey")
...

Kotlin/Java: With Intents

The data will be passed as extras into the intent that launches your app, accessible by calling the appropriate get method (based on type) e.g.

Kotlin

intent.getBooleanExtra("isGptDriver", false)
intent.getStringExtra("stringKey")
...

Kotlin/Java: With Shared Preferences

The data will also be stored in SharedPreferences under a file called prefs.db. This is accessible by fetching that SharedPreferences instance and calling the appropriate get method e.g.

Kotlin

val preferences = applicationContext.getSharedPreferences("prefs.db", Context.MODE_PRIVATE);

preferences.getBoolean("isGptDriver", false)
preferences.getString("stringKey", null)
...

Pass data

To initiate tests and pass launch parameters to your app, you can send a JSON payload to our executeTests endpoints.

API Call Payload

Your JSON payload should have the following structure:

JSON

{
    "organisationId": "<ORG_ID>",
    "uploadId": "<UPLOAD_ID>",
    "launchParams": {
        "<KEY1>": "<VALUE1>",
        "<KEY2>": "<VALUE2>",
        ...
    },
    "testIds": [
        "<TEST_ID>",
        "<TEST_ID>",
        ...
    ]
}

Here, launchParams is a JSON object that contains key-value pairs you wish to pass as launch parameters. You can add any number of keys and values to the launchParams object based on your requirements.

Example

Let's say you want to pass a launch parameter version with value 1.2.0 and featureFlag with value true. Your JSON payload would look something like:

JSON

{
    "organisationId": "org12345",
    "uploadId": "upl67890",
    "launchParams": {
        "version": "1.2.0",
        "featureFlag": "true"
    },
    "testIds": [
        "test01",
        "test02"
    ]
}

With this setup, the defined launch parameters will be passed to your app when running tests, allowing you to simulate various conditions and configurations during your automated end-to-end tests.

Last updated