Integration Testing

Contents

Testing Branch functionality can be challenging. Many functions require two parties to complete, and some tests can inadvertently affect your analytics data. Here are a few workarounds to help you test Branch features to your satisfaction.

linkThe Test sandbox environment

Branch maintains both a Live environment and a Test sandbox for every app. You can think of these as separate apps in the Branch system that are simply available from the same Dashboard for convenience. There is no data crossover between the Live environment and the Test sandbox, both offer identical configuration options, and you use different Branch keys to access each one. Links respect the configuration settings of the Branch key under which they are created.

linkLink domains

  • Links created with your Live key will begin with XXXX.app.link
  • Links created with your Test key will begin with XXXX.test-app.link
Universal Links in the Test environment

To enable Universal Link behavior for links created with your Test key, you need to add the following Associated Domains entries:

  • applinks:xxxx.test-app.link
  • applinks:xxxx-alternate.test-app.link

See here for more detailed instructions.

linkSwitching environments on the dashboard

Toggling between these two modes on the Branch dashboard is simple:

environment toggle

Caution: Configuring the Test App

Since the Test and Live environments are completely separate, you will need check that your Settings (especially your Link Settings) are properly configured.

linkSwitching environments in your app

Using the Test environment in your app is easy:

  1. Go to Settings
  2. Make sure the toggle switch is in “Test” mode
  3. Grab the Branch Key (it will start with key_test_).
  4. Simply replace the Live key in your app with this one (but be sure to switch it back before release!)

linkSpecifying both Test and Live keys in your app

For more advanced implementations, you may want to specify keys for both Test and Live environments (for example, if you are building a custom switch to automatically select the correct key depending on compiler schemes).

Open your Info.plist file in Xcode, change the branch_key entry to a Dictionary, and create two subentries for your keys:

environment toggle

To use your test key with Branch, set the Branch.useTestBranchKey class variable to YES before initializing Branch, as shown below:

[Branch setUseTestBranchKey:YES];
Branch *branch = [Branch getInstance];
[branch initSession.....

linkDebugging an individual link

At any time after you create a link, you can see all the information about the that link by appending ?debug=1. Make sure you are logged into the dashboard, are on the correct app, and that the proper Live or Test environment is selected. The link debugger allows you to select a platform and browser, and see what will happen on link click. The debugger will also show you all of the data associated with that specific link.

dashboard debug

linkUse debug mode to simulate fresh installs

Branch intentionally adds a lot of restrictions to prevent install events from being triggered on app updates and reinstalls. Of course this can make it a challenge to simulate fresh installs while testing, so we have created a debug mode to help you manually override these restrictions.

To enable this mode in your test builds, add a setDebug call to your AppDelegate.m file after you create the Branch singleton, but before you call initSession. Your code will end up looking something like this:

Branch *branch = [Branch getInstance];
[branch setDebug];
[branch initSession.....
Caution: Disable debug mode before release!

Make sure to disable debug mode before releasing your app. You can do this simply by removing the code you added.

After debug mode is enabled, do the following steps to verify your new installs are being tracked as expected:

  1. Uninstall your app from your device
  2. On your device, open any Branch link
  3. Re-install your app
  4. Confirm an install event occurs by looking through the SDK’s session initialization callbacks