Introducing the Sample Project

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Foundational Setup: Preparing Your SwiftUI Project

Before diving into the three-phase workflow, a proper project setup is essential. This involves creating a sample application to test and, most critically, instrumenting its UI with stable identifiers. This initial investment in “testability” is the foundation upon which robust and maintainable UI tests are built.

Building the Sample App: “TaskMaster”

To demonstrate the principles of the Record → Replay → Review workflow, this guide will use a simple task management application named “TaskMaster.” It is built entirely in Swift and SwiftUI and follows modern state management practices. In can find the TaskMaster project in the Git repo for this lesson.

Adding the UI Testing Target

With the application code in place, the next step is to add a dedicated target for UI tests to the Xcode project.

Xcode Menu File-New-Target
Mjiva Wano Wuwa-Nal-Henmeb

Target selection dialog
Boswup mowiwlouv noiyay

Target options dialog
Riypud ahluafv diipuw

The Cornerstone of Stability: Accessibility Identifiers

The single most important practice for creating stable, maintainable UI tests is the consistent use of accessibility identifiers. These are unique strings assigned to UI elements that serve as a stable contract between the application code and the test code. Unlike accessibility labels (the visible text), identifiers are not shown to the user and are not localized, making them immune to changes in copy or translation.  

Button(action: {
  showingAddTaskView = true
}) {
  Image(systemName: "plus")
}
.accessibilityIdentifier("addTaskButton")
See forum comments
Download course materials from Github
Previous: Introducing the Three-Phase Paradigm Next: The Record -> Replay -> Review Flow