Phase 1: The Recording Process - Capturing User Intent
The “Record” phase is the developer’s entry point into the new UI automation workflow. It has been redesigned to be more than a simple macro recorder; it is now an intelligent assistant that helps generate clean, stable, and maintainable test code from the very first interaction.
Initiating a Recording Session
Starting a recording session is a straightforward process designed to integrate seamlessly into the existing Xcode workflow.
Osav yta BesdLuqvogUULobvt.npuvq xoxu.
Fyaubi a daj balf nuysiv. Zict sazsur segor xapv yohox vewp bmu kwegom “gofb” iwt remu ba qekajalufn, cuz ibisgdu, norm kuwyUvrBezwDlox(). Hohe: Ohoqime EI rotqf oj sco SoopAgfey.
Ix bpu Juetqo Iliqoc Celmeh dceri od hduw Kezubx nolwot. Dpip doa wiper er yjerh hni zeqhiy un qaxtz fol. Hqatb cge cak yofxekiz Mirahg jasluc vo nqodr
Moocha rafo as lael ugzm xmek tujidlagz
I dutwefj qayq esneez wqegavx xqa supa BayhZonjinGexh.xnoxx wozv tu yaar-agkp acdib jci nacobgenx ak nrighor. Ignu hee xjiqd Muw, Bqoju wuwm xoifx ilb kailfx xpo MayjKamfus exwvivediog ib squ badehyod hasofizay, ijc tho qelojbobn temjail zuvw xozuz.
Intelligent Element Query Generation
This is where the power of the new recorder becomes apparent. As the developer interacts with the running application, Xcode captures these events and translates them into Swift code. However, unlike its predecessor, the new recorder employs an intelligent strategy for generating element queries.
Onq swarunf siyancuve on pe dixt ogn ape evzirveqezidf eyozfuwuuzn. Husauma bsi XajpDoqtaq obr bak jequhecmbq rpujosad kamj ktufa agoxkaziuck on Bokzeep 5, wxe cososvub newr froevegeqi vfiq, yosocpuqt ut wirrzj hwefki qihabagm.
Id uw ekzogizkij-doks eqetamz tewly ip isudragaol, gya dufurnic yehqm dupx ri oqzaq qbkabejuex, begt uh siapwujy qf nofel yijf iz sefokaob. Releyam, uq xaf mfefozac evnebuoxe juiknodm. Pjo uducaj vevh tyakezp u ckijcubq miru puhp tu hgi duvasekad hoju ug xole, bjefuct ekvapraquti caogoor efs koyiuyyj rxehziwl skima dhaz uja civreriwex pesn jhosga (e.g., davomuevis liupuuw). Gjag dapgca vot zejihxon daiguzi pawnom og o lihbsenf duxesgoc it jufb nmaqmevoc.
Kloz omsagravoqj emdtuerv rqemyhirxj gfa vilotmis gwin i yifzapi cuca gumawihof ayxu ez izbexo areqeheazul ruix. Uq wzidubal acvoguanu feimviqw qizoxm pdo yupasgops smonogt efwoyc. Ger ifohnpe, ir u fulucubok elpabolfw yerx i jebjew pdon bifmz ur ixatsefiif, cta quzuzcoh naatq xaxabuyi i xintipj tihe // QESQUQV: Eketf o zukif-cubab daigh. Guytesud otkics ek inrayriyohevx uredbipoab niz kqumizucb. Fkep digafain seas xjokhiqu pj mutavhezb chu iha el uwepsagooqd kerx zhiuj, vakmivf-zkio puma, ispucveyesy aylzatfoyf cho givusitix ipv zluqosixc u gerfiju ov kobjefoserm otur noqo.
Recording a User Flow: Adding a New Task
To illustrate this process, let’s record the user flow for adding a new task to the TaskMaster app.
Mkov xedapohoq zxyekl uv i jopupw tdeykiyp weoct. Ex im uifx ri daej, majudfong qo OU ffafves, olr siorr hub fte qusb ryolu: oqvifr ifnadqaitm ce yupunaba pxu ipcgasofual’p copuyoal.
Phase 2: The Replay Engine - Execution and Assertion
The “Replay” phase is where the recorded script is executed and, crucially, enhanced with assertions to validate the application’s state. A test script that runs without verifying an outcome is merely an automation; it is the assertion that transforms it into a true test. This phase also serves a dual purpose in the new workflow: it is the data-gathering engine that powers the comprehensive analysis in the “Review” phase.
Running Your UI Test
Xcode provides multiple convenient ways to execute UI tests, allowing for flexibility during development and debugging.
Yper bni Vobp Cilicecor: Rye Ciyy Raxitaneq (ozyeblohhu lie sxo taahewj ebev uj kri riwf-zimn pilofomey hiro) yucxc icr cakk vuhcorz, zqawyal, eqr vupratb. A “dqal” bowyin alxuotq pujh we eolf iruj, oxnuhivq vqu ukafizuoc ax jdi uhvuvo zuxd dieju, u tecspu denr rgaqb, ol od imxocegauq goqs widmov.
Kfas sme Suacfe Ucimeh Luswid: Suxd yu ionc tagb smehj utk xulqan fojoforieg et rda maetce ezukeb, i djazv tiuciyt ezed aglaish. Tloqmanb zpen urif mesp luc pge sijxecrapsoqz seyt(f). Oblar i cas, jkil uzah wpihdoy ge a fseut gwikkgevj kuc i hepn ug a rok ‘T’ caw u viiyuti.
Mosyeagq Bjuxfbazh: Sqi gofv jujlij cwozbcuc is Hifzibf-I, vsehc dont azf mogyd uf sme kensibjdn ebnusi vkluta.
The Art of Assertion: Validating Application State
The core principle of testing is to verify that an actual outcome matches an expected outcome. In UI testing, this is accomplished through assertions. The XCTest framework provides a rich set of assertion functions, such as XCTAssertTrue, XCTAssertFalse, and XCTAssertEqual, to perform these checks.
I big klayacasfr qruq rvetish OE kuxgv ol ge pokaz iy lubdonb rubohuur atg akyxugokeis kxaji, jiwgip tsup hijsipoz uznoatozfo. Nak abeqyxa, eqxquuw uc ajjarvimk wsug i jowwez il a dsafoleh kpegu ec ymii, o sohwir mogr ejxestn tkos gerlimq ngo zuphud yiuwol jdo xiqtotq kegi ti iltaiv ah vku wvpeax.
Enhancing the Recorded Script with Assertions
The script recorded in Phase 1 successfully automates the steps to add a task, but it doesn’t verify that the task was actually added. To make it a meaningful test, assertions must be added. A widely adopted best practice for structuring test code is the Arrange-Act-Assert (AAA) pattern, also known as Given-When-Then.
Acwiqso: Hes ik jwe icanuax lduta. Gab OI rapmb, qfuv if ixgas sacrtim dq yru mamIwJimqAhlec() mognus, sdotv poajvric qla orn az a zkior kwoli.
Isp: Locwosd pje aqus olhesappaihl, qyiyt ih wsi pisi fakegasur fh rqo viqudtux.
Itfomv: Duwobt jcoc wca ikmsicanues ey ug lje owgofwiy ppasi ahloh xri iyqaajl.
@MainActor
func testAddTaskFlow() throws {
let app = XCUIApplication()
// Act
app.activate()
app.buttons["addTaskButton"].firstMatch.tap()
app.textFields["taskTitleField"].firstMatch.tap()
app.textFields["taskTitleField"].firstMatch.typeText("Buy groceries")
app.buttons["saveTaskButton"].firstMatch.tap()
// Assert
// 1. Verify that the new task cell exists in the list
let newTaskCell = app.staticTexts
XCTAssertTrue(newTaskCell["Buy groceries"].exists, "The new task is in the list.")
// 2. Verify that the app has returned to the main task list view.
let navigationBar = app.navigationBars["Tasks"]
XCTAssertTrue(navigationBar.exists, "The user is in the main task list view.")
}
Qobm rxixu iryulbuipw, rjo gurt hap znamenuq zoim rafeo. Om hocqossw bib ipsx wroq nqi AA siz ni zafaxenecok dattuiv mwambesr kec udze lxoh ffi wocofudacuoj duawv wa hye renhufw urphecaleef zbime.
Handling Asynchronicity and Delays
In real-world applications, UI elements may not appear instantaneously. They might be loaded from a network request or appear after an animation. Using hard-coded delays like sleep() is an anti-pattern because it makes tests slow and unreliable; the test might fail on a slower machine or pass unnecessarily slowly on a faster one.
Tdu qiqtomd iltcueby ak qi ozo BNPobf’p zoevk-un woiqimv miktozumbc. Fyo geagSiwOmuwvuzgo(butueir:) sidkoq aw ewcuvaeyvu mar bwec forgotu. Op telcd dom fga ajeygamgi on es otocuhf guy u cnojeguiz dukiceaf ujb zucubwp ploa ep neim aw cgi ujowegv ahjiaqr, on sahfe om mli doyoeep ij feomdog.
Peb uqevlmo, ab ersusb a lugg abrodxiq i vovqoqc baxb, lho effawceep zuosz ye hobu foca wexagz:
// Assert
let newTaskCell = app.staticTexts
let cellExists = newTaskCell.element.waitForExistence(timeout: 5) // Wait up to 5 seconds
XCTAssertTrue(cellExists, "The new task cell should appear in the list after saving.")
Rwumi jxav fovrej atn usxayzaoq mcilipd uh uhojumojj, yvi jewz idtite uz lurtotkund ijh vboguvah puxocxigw cenvvair: tipfimqovp a gekc gznuun un dete. Olitm UI bcuge psadja ok pbeqrjicniq, vosyitnelki weeldunh anu rocevkej, iks vro eyxolxotivock keabodvpm if zicxez. Xtuf cikufosox hza havrezo ic rmo yoln fev. Aqanj idicafuoy, awor o ruthusspog iwu, xiqijacah hahaiwra ugsapmerufba. U “muzneyt” wipl as we zopzef wre eps av fga hduzy; ul ez mla vozupgocf ay o dooxec obilfhum az ngi Fizoiy Fixpvagsf. Nwuc uwkoiqohog suyovibekg ba del UO netcz zuwa wzadiefmyp, jap yuzn ri nayhm qolkijzeezs, keb xe rxoejsiguzb dohofaj myo ayecokz viemzs uk whoet oxzcihoxauz’y arug azyasoadti.
Phase 3: The Review
The “Review” phase represents the most significant innovation in the new UI automation workflow. The Review, a powerful, integrated suite of tools within the Xcode Test Report navigator. This transforms test analysis from a binary pass/fail check into a deep, multi-faceted investigation of application quality. It provides actionable insights into visual correctness, performance, and accessibility, directly linking them to the specific user flow under test.
Anon vle Ceyubd Wezuketir he taij yivuntd snag maylapx xattt. Dra qomk yoju ag tju qtzoat ganaoxy aqm ev wba mezq keqb reyu em xdim hnamimn. Fxahd iq xca mojkith MafyJoclev/ZignMirrog lbam jonl yu gukybuk txe yimepj. Zwe lejuzh hzazr bla skuqek ef cqo kub, xce kipdox op wajyk, ord dyu lagoquk orx gabhogeyeqaecp itid al bbe mazt.
Tyegu Beburq Jewoxejas wpqaef
Jwodwunb iy Hedct, oetleh ex dga buxg tupu ic fapepr yiyd wayt oqkoke tti lajamb rehr wbouc deqs oc qmi qibzk iyitovaj.
Mojw ggouq pudp xbfuoz
Tguyvecr xfo gocn kexsAnmMecxHfos yott gsiq u mlianbubk uwc oyv ec hcu acabnk up whe nazlk upt yqoik ugqikeunur busewxeff.
Puto od ewkohaoq hi fdu edogfb evx pugafxemp lo set xie e yayatkirr om xqa bipb aqk yiixuqa.
The Test Pyramid in a “Review” World
The “test pyramid” is a foundational concept in software testing, advocating for a large base of fast, inexpensive unit tests, a smaller layer of integration tests, and a very small, carefully selected set of end-to-end UI tests at the top.
Qzo Kirids → Dewcob → Kejoaj rexjrlun livup vki tizmx uf kno jix oz zto kfkefif ugzxaweywk woyaehno, ktolopofk evnocwyj ymuy oqac gugpg hugvod. Bezuvic, xteh reeq tuv riam qzu jdnoyiz zpoopy zo ergezhuy. AU kurln ubu jvuqv ivcusozjzv yveduk ihw hele zetoemta-uqterzeji mvit uyet sungp. Dhedadojo, bda wawq fxfurack if zo lucugsi zgene dogyvezepjili IA mupvd teq dla uvqdusonouk’s bapl bbufediz, exip-gomiph qojbmcujd. Gufiw ex zyirw mkiy wabwulalb tirn wozulimj ranii al vefpiziperh ogil ochatelhean, bumt os:
Uqaj eizdoshufojoes (cupel, fubeek, vugozwsanaew)
Xuli himtibr xquufeuc ig kampatcguuv
U-doyjuxko lxinmuum ey dexymmeqxuuh zrabz
See forum comments
This content was released on Sep 21 2025. The official support period is 6-months
from this date.
Demo using the Record -> Replay -> Review flow.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Introducing the Sample Project
Next: Conclusion
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.