How to Test Deeplinks with XCUITest

Make sure your deeplinks are working

Gokberk Ince
Trendyol Tech
2 min readDec 7, 2020

--

Photo by Wesson Wang on Unsplash

Especially in e-commerce applications, functioning of deeplinks is very important for the user experience and the company. Since the manual testing effort of deeplinks is quite high, it is critical to automate them to shorten the regression times. As Trendyol iOS Team, we are using XCUITest Framework to make sure deeplinks are working fine.

Formula 🧪

We prefer to test deeplinks with safari approach. Basically,

  1. Set the app state.
  2. Open the Safari app.
  3. Paste deeplink URL.
  4. Make assertion to pop up is appeared.
  5. Press the “Open” button on the pop up.
  6. Make assertion for the expected view.

App States

Make sure to cover all app states in your test cases because iOS processes deeplinks differently depending on the current state of the application.

XCUIApplication

Use this class to launch, monitor and terminate your app in a UI Test.

app.launch() -> Launches the application.
app.terminate() -> Terminates the application.
app.activate() -> Activates the application.

Launch Safari with XCUIApplication

You can init XCUIApplication with bundleIdentifier parameter.

let safari = XCUIApplication(bundleIdentifier: SafariIdentifiers.bundleId.rawValue)

You can launch Safari with calling the launch method.

safari.launch()

Open Deeplinks with Safari

Now after that launch the Safari, the rest of them are just basic UITest steps.

Sample Usages from Trendyol iOS UITest

in setUp(), we login the app only once then terminate the app.
Trendyol Assistant deeplink
Encoded Instagram url deeplink (It should be open in-app with in the webView)

Thanks for reading. Providing ideas or commenting on current practices is welcomed. If you are also having trouble applying them, feel free to contact me. 🎉

--

--