22.5 · Snapshot tests and UI tests

Snapshot and UI tests are where a suite becomes slow and fragile. Used with care they protect what unit tests cannot see; used carelessly they are the reason people stop trusting red.

Mental model. Make the app start in a known state, give elements stable names, and wait for conditions, not time.

Pictures

Reference images, text snapshots and why they break.

  1. How do snapshot tests work, and what are their pitfalls: rendering differences, dynamic content, size, and review fatigue? 22.5.1 · L3
    A snapshot test renders a view (or a value) and compares the result with a stored reference; the first run records it, later runs fail on any difference.…

Driving the app

Identifiers, page objects, launch arguments and stubbing.

  1. How do you write UI tests that stay stable: accessibility identifiers, page objects, launch arguments, stubbed data and waiting? 22.5.2 · L5
    A UI test launches the real app in a separate process and drives it through the accessibility tree with XCUIApplication. Stability comes from a few habits.…

More in Testing