How to Test Deeplinks with XCUITest
Make sure your deeplinks are working
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,
- Set the app state.
- Open the Safari app.
- Paste deeplink URL.
- Make assertion to pop up is appeared.
- Press the “Open” button on the pop up.
- 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
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. 🎉