iOS-Testing-Automation-Framework
Robots, self-healing locators, screenshot diffs, accessibility audits and CI reports for XCUITest.
License: MIT
A dependency-free Swift package for the UI tests and unit tests of iOS and macOS apps. In XCUITest it adds robots, lookups that survive a renamed accessibility identifier, an accessibility audit, screenshot comparison with a difference image, and JUnit and Markdown reports for CI. In any test target, Swift Testing or XCTest, it adds SwiftUI snapshots, polling waits, retries, spies and seeded test data. The rules behind these helpers are plain Swift and covered by unit tests; the XCUITest layer is exercised by an example app's UI tests on an iPhone simulator.
Features
- Robots: one class per screen whose actions wait until the element is hittable, appear as named steps in Xcode's test report and report failures at the test's line
- Healing lookups: Locator and LocatorHealer fall back to the label, the placeholder or the most similar identifier, log the fix in HealingLog and refuse to guess between equally good matches
- Accessibility audit with five rules (missing labels, unlabeled images, touch targets below 44 × 44 pt, labels that repeat the element kind, duplicate identifiers), optionally combined with Apple's performAccessibilityAudit()
- Screenshot and SwiftUI snapshot comparison against baseline PNGs, with a tolerance, ignored regions and a difference image; a missing baseline is recorded and the test fails
- junit.xml and a Markdown job summary rewritten after every test, with registered secrets and credential patterns masked, plus FlakinessAnalyzer for results from several CI runs
- typeSecret pastes passwords instead of typing them, so XCTest's own activity titles never contain them; CI searches the result bundle for the test passwords
- Unit-test helpers: Wait.until, RetryPolicy, Spy and ThrowingSpy, seeded Fixtures and Benchmark
- No dependencies and no Swift Testing import, so the package links in UI test bundles; 118 Swift Testing tests, 9 UI tests in the AutomationShowcase example app, and a DocC catalog with four articles
Quickstart
1import XCTest2import iOSTestingAutomationFramework3 4final class CounterRobot: Robot {5 var label: XCUIElement { app.staticTexts["counter.label"] }6 var button: XCUIElement { app.buttons["counter.button"] }7}8 9final class CounterUITests: XCTestCase {10 @MainActor11 func testTappingCounts() {12 let app = XCUIApplication()13 app.launch()14 15 let counter = app.on(CounterRobot.self)16 counter17 .tap(counter.button)18 .tap(counter.button)19 .assertLabel(of: counter.label, equals: "Tapped 2 times")20 }21}Installation
Xcode (File › Add Package Dependencies…)
1https://github.com/muhittincamdali/iOS-Testing-Automation-Framework.gitSwift Package Manager
1dependencies: [2 .package(url: "https://github.com/muhittincamdali/iOS-Testing-Automation-Framework.git", from: "2.0.0")3],4targets: [5 .testTarget(name: "YourAppTests", dependencies: [6 .product(name: "iOSTestingAutomationFramework", package: "iOS-Testing-Automation-Framework")7 ])8]Screenshots


Timeline
Repository opened as a test automation framework; most of the following week went into documentation
v1.0.0 released with a README-driven feature list, after README, issue-template and CI/CD work that started on 28 January; README and docs changes continued until 5 February
Sources replaced with placeholder code: a visual regression engine that compared nothing, an accessibility auditor that only printed, and a test target that no longer compiled
v2.0.0: rebuilt on Swift 6 with tested rules behind every UI helper, an example app with UI tests on CI, DocC, and the useful parts of iOSTestingTools merged in