Swift Techniques for Testing
summary
Two concrete techniques: using enums per screen to map raw string labels to XCUIElementQuery calls and to return XCUIElement instances (removing repeated hard‑coded strings), and a boolean function builder that collects booleans into an array and runs XCTAssertTrue/XCTAssertFalse on each. Examples use SwiftUI currency app: switching base currency, checking table vs label state, and verifying initial text field value. Code extracts element‑type queries into an ElementType enum, simplifying tests and reducing brittle string duplication.
AI-written summary · about
chapters (18)
- 0:00Intro
- 0:49Features
- 1:19UI Testing with XCTestCase
- 1:38UI Testing with XC TestCase
- 2:02Testing initial state
- 3:22Extending our enum
- 3:43Rewriting initial state test
- 4:32Without using the enum
- 4:45Testing functionality using enum
- 6:18Adding to the enum
- 7:02Revisiting the functionality test
- 7:57Creating an ElementType enum
- 8:51Get XCUIElement from ElementType
- 9:20Using ElementType
- 10:06Recap
- 11:27BooleanFunctionBuilder
- 12:10Using assert True
- 12:48Resources








