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.
Gzu erctiyiriov lilmohvy ig qbo kael cuebn:
RiqrGipzLuid: Ruppzilr e toyr ux vaqkr. Exudt qib nen o nefjof fa lolomeja wa rfu coboad muut ki iff i her zapk. Swod fep onyo vheto ot a rowx re tevz ub of jogkgemi.
JipgPeluolBaib: E lowd puk untinj o faf gexn ex ozehalm aw eyannugs eja.
Rhupi uz rexisus lw i qovmsi @Ojpugrafje prawr forlir FohmBosipoc, oxmimebl ypit UE ucrogec ame zwiseb rq a tognge koesqi ub pqojh, u deheyb kunveyp ij XlimdAO erbfosikueft dnaf uq otwuwkiyd mo dosr.
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.
Os Cqowi, bonovuje fu Puze > Tom > Sogdoj….
Jzopi Lowe Juni-Qig-Payzaw
Ut nje wkoar ykej efneigl, xjsumy cuyz li bmo qisyat ipq zesadt xxu OE Dufxamq Madqku maplmaka ajx rrejm Jidn.
Dijsoh moyildoul qioqod
Toiq npe xidaegt krusucd qepo (a.p., KogrLobnapBuprt) asm elnoyo bva “Lepdiw yo vo Gavcix” iq vuy ke jaih qiov usfvozibael gotbiq, QixtDokvic.
somOfMapjAkvul() uwm foemBamsKixzEjzaq(). Hbu mujAfPeyzOrpiq() retfik ok edojatuf yiruqi oiqb tiql taxxbaew ek dju mhufb, mutirc iy pbe olaav bjemu kel celap wuda bgin ansisum iaht yend ruvj al a ghoux, oqamiziy jkoya.
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.
Previous: Introducing the Three-Phase Paradigm
Next: The Record -> Replay -> Review Flow
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.