How Banksalad's iOS team writes test code as naturally as breathing, Part 1 - Integrated UI Testing
Key point
Banksalad's iOS team resolved the dilemma of introducing tests without modifying existing code by using integrated UI tests built on the accessibility tree.
Details
The Dilemma of Introducing Tests and the Role of Integrated UI Testing
When an existing codebase has no tests at all, writing unit tests requires modifying the existing code, which in turn raises the risk of introducing bugs—a 'chicken or egg' dilemma. To solve this problem, Banksalad's iOS team first introduced integrated UI tests, which allow tests to be added purely without any modification to existing code. This approach can be applied regardless of whether UIKit or SwiftUI is used, and serves as a safety net that prevents core functionality from breaking.
Principles of Accessibility-Based Testing
For integrated UI tests to work reliably, the app's accessibility tree must be properly set up. UITestRunner finds UI elements through the accessibility tree in the same way a visually impaired person would use VoiceOver. Therefore, a button that cannot be used with VoiceOver also cannot be found in test code. When a test fails, the accessibility layer must first be refined, and this is a safe improvement process that does not affect the existing UI visuals.
From LocalUITest to CI Smoke Tests
To get familiar with XCUITest, Banksalad first introduced LocalUITest. This is a test that runs only locally, not in CI, and was used to automate the process of going through complex procedures (sign-up, asset linking, etc.) to reach a specific screen, reducing the hassle of manual testing. As the team's proficiency grew, this was expanded into Smoke tests that run in CI to check core functionality. These run every 4 hours via GitHub Actions, with a structure that sends notifications on failure.
Ensuring Stability and Verifying Edge Cases
To ensure test consistency, the team used xcrun simctl to extract the unique simulator ID for specific conditions (iPhone SE 1st generation, iOS 15.0, etc.) and fixed the execution environment. They also run tests at the largest text size (UIPreferredContentSizeCategoryExtraLarge) to discover layout bugs that are easy to miss through manual testing. For log verification, they improved accuracy by using the app's Developer Center feature to look up logs and leveraging NSPredicate to check the number of UI elements containing specific strings.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.