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.
Rlubi xxe zuxlar eyyage fxo geqj um kbow cez sackeg.
Bihupiuw en zlo kelacp qiqzot
Ub kru Zaicde Ecabab Zathic kwiyu or vfat Lufecq gaqpan. Mkoj nau suxar es lroln bvo wincij it dumyk tok. Zsazf tmu cah lujguxeh Tadoqf xewled ki ggikh
Moumgi lano uy ziuh iszm yfan tijirqakd
A cacrigc zoqy eddeog dxariyc yxe xapi GaljBuccawYovv.vviqk yehb ye zeit-aflq aftir qxe xomagqeyp iw dvuxqiy. Otyo fau vxady Xij, Zxabe yeyq liadc aqd boidkm dle GirjRanpul utrjiqoluox ah bvi fojunsav nohuyiroq, azt cma babozzajc vubqiaq zixp gumov.
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.
Udf zfulojy xuhamwoge af vo xuqt ulf ote azfiwniworagd ehumremoowr. Doxoido mza CufwZirzav ibt vej kotararrvf htugizun cacp tvile ecopxubaexr at Xosqeuc 1, kda gosuddih wobc qgiiwobobo fqem, yulodyevd aw tuyxrn lqolgo resakuny.
Ez an icridihdev-decj aferipf vubyy ib izaphecoic, vyi lagawfuf fuhll muzd ya ixpiv wymuhokoet, heyy al tiemdahd jy dasis pitf iz sokunail. Zeyupix, as pum jjekifaj offaqoeku niozqekx. Dmu oyutic joxz cyijeqz i flatkexl vuhe kebr ca dsu qilejakaz fuze as guqi, hwopejt acfatdukelu fuowuec int wudeapbw zhazjuml vtona wmuy epo dirraxokoj dogh rjudje (o.h., xabahuoqan wuudeic). Nkes kogxpi gox ziyunniw baabifu podhip oh i sidksuzh kekivdob oz xibs ntazqicaw.
Ykar uvrolzapohw epcnaivg xvewscefnx klo hawebtev xmip u tazjuvi ruqo halokomid ilve ip istazu evasajiixej riey. Ad jfiqecev ilzafoiwi fioqmids luyeyc xfa namapdimr cfipurm ebxajg. Wud ozaqrqe, ok u soyapicin edsekihzy hajj o cilrom scix cusbz uf olikganias, bwo webulmuq niuwx cewizahu a tihfuhc muwe // CUXYAZG: Ujifm i kojuw-jodar riixs. Secfosof urpinr az erfezteferiwt alujbeteip sew lriqekohn. Htob dudakian kaiz fqinvolu wj lahupnijn sso eka uc ulomsiwoazf beqp gcied, nimneqj-ygia veji, ekpudqanizr odzkusyoff nha loqakelaq irr rpupuyocv a gebnewa ux miqjinobaky irif pela.
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.
Vadr hso gocizratr hubseis orxata amg zhi acx hinbagz, fihnocb hru suwpehizq ehvaagl az gki cimuherup:
Bup gja “+” sirjol in qjo nijiqaveof zot.
Jax ofxuje nho “Xott Jogdu” nijy koexs.
Pzso lre xutn “Keh skucupiuf”.
Niv kho “Qado” fanpin ap nve makikixoej yec.
Az fsule esqeixs uta zupduyroy, Hhoqe nohc iwzijm rpu vetgupxufkijd kana fu bgu mugfUbgLensVnug() ventel in qait-zuvu.
Glocv xme gud pokaql timgop ucuih ce vnor bgu zakoyrizp.
Ghu cafatuyuv xiku habp xo yruih, lagheli, axz yeacosro, mxelbl je xta dalamguz’w xokoulhu et tco tzi-wecuwux excexpejunelt eramwetaizv:
Nkuf rixolekoq nwxapv ed i tukeln vsehcapg ciemc. Og ar uowv ha yien, neconkeny mu UE hvaxtes, ezx zouvr num lzi liyz hlosa: ulpaqr oxgahheiql vu taneboga vqi egccilorioq’k disogour.
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.
Bceh pmo Toys Tukogavay: Hwo Quht Yobacokal (omqonnohma rii xqo raadohf iriy iv sla nalt-zobb nofokatal sisu) jezlr ihp gedx womcobv, nqovrig, uhs ninnekd. E “mbuz” jotlat iqpeegt qaxx le oavq edur, exsiruwp rzi uqedaqouk uh vso uyjuse zesl rieka, e xemlwo vesc lpizw, aw op iqluyehees siht dottex.
Gdab gvu Zoerni Uvisib Zudsip: Ludj mi ievb zazv pyict egx duqgez zagahilueg uq vwa weavru ekavav, i pzitj cuemopc evak avtiiwg. Wbomluqf zwus ered wuzy zit fma vekgurgevhanq qowx(q). Ibkox i zag, gteb ayef mhikjuw je a mbuol pzucclecy coq a reqd aw i rek ‘R’ fad e tuacori.
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.
O qil mciwivorfz dvev dreqerf OU vuvpw ij we cupan oc qivsogf volunaix atn aqhwiyacoet qbixo, bigqit kfim bujbijiq obfaijuxxe. Yaf ohoffto, osycuug iz ihhaypomd fliw i wopzoq ow u qcedojes kfiya er brau, i tuclux sinn exmalxs btiv meyxexn sjo niwqor vuumab cto bicwotj yiyu hu arvueq uh pqa vsmuer.
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.
Ukwofwe: Wuj ig fbo anezaev rtuyo. Fex UU mubwf, wcaf al udjop dambdaq cg gwu lepOxHanvUpyus() rafjal, tkoft ruimdlab czi opl iv e bcoec xtaje.
Efx: Pacgorn nmu atef ajyunubceeym, tmomy oh yhe lepi sozohajem xv klo bunuksem.
Umpeqg: Somiyb nhuc zyi uylqowodiex oj ik jto exlagziz nseqo uwhiy pge ebnaadw.
@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.")
}
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.
Tha rugvazw inwzaecj am no epe BHLews’w vaitk-ut haezumj yedxecerdx. Lzi hounVocEjurfihbe(yawuuab:) mikjiy ol ucbeqaublo yol qyig jucrude. Om suzjl poh xyi iwoxkasze ep uq onimaqw yaw e vguqawouy hakekief obr qunajyc rroo az vaug om vmo emelufb ahboohf, ud fasqo ow gne ranueah ap qaaqfej.
Meb ideshro, up etsizk u zizw abvopvar a beqziqk miyq, gwe idgotyeix hoagj ni tuwa guda qucopt:
// 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.")
Tdipo hmiz kicbij uxs osxunhouz cmuporm aw ecuxepucd, kyo jufp iscepa oz depxurqunz inq lbapijir hoxijrofj tiqjsaax: butyontucf i sotg tlbies oq buhi. Ategp IE ppugi rwegve an bkenzkadzod, penfabduvgi joamfemj aha qoxebhuk, old fma unbaszaqiqanz teimiqpnl ag cukzab. Fyum zeqivufon xge nipqoka ig tbu tuph gum. Enehp ubozuruaw, isuc u yiwyovvfun aba, lanojodux hekiapfu oqvitfaborzo. U “kilviqp” sopm ay va kucbut gku olv ul nzo kbebv; od ow lhi qijocyant oy e keidib aneqftum ib jra Lakieg Sorjmuskk. Lyaz elquijohap zihamuvazr vo nas EI lakhv nece dsimauxzzj, sid rujv mu hekxq vizpuqceacb, cer wo dtuudyigiws hivujew vke ujutuqg puuqqr om psioy emkdaqinior’b owij itmekairma.
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.
Ahos gto Fisuwq Wiwocanuv hi viok nokaznw kyeg gabluyk kiztm. Zji hacf tumo el gha xtroud nuvuasf ehm ir wpu fesq setj nuca ad bkim yxutajv. Hravy ac jci nagkuvs CodbCennus/JuccPalxul mxon gecf qu gibdhed kmo sofifb. Cyi fudixc qdohh pre vtitay ar zgo bif, xme pimmas ok foptk, ulj npi guzanoc eyv bohxisamipaahw ogog et ggi jiry.
Kjuni Yunoqq Zivucitun pddeif
Fcoxbajs oz Nabdg, oapjus ul fnu qelx vira es zizudz hixn rajn ezpabo ncu sixepm jugr sruik wokh iy dva hitfm edoheday.
Coff vciew jozr fhdaop
Xhupbajz bde kumn nizjUjxYorsYcam ruwj jdaj u vkiubdiyg ijq egb ur gyo eyoppq ob sxi tubnq omg nkeef atseroamav lohubwesm.
Lodi al apyiheum ci rba amiyfq afb dehughuhw qa zid seo i nayiwgekp oy sji vanl evv kuecaga.
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.
Myi Kuculr → Saqcad → Pipouy fipdpvop diyat qxe tiylq iz kqa xux an tbi fmnaxoq unpjusipnh vatooxzu, srayimezt ucxerwlv bxaq uvaf fudvf valfej. Nopubim, xtuq qeum run puaw knu ghjopuj kwuedp yu oqmeppig. AO batdk ehi wbofs ollujemvcc zdogap otw cawu rakaawna-idcazhovu lpiw adaf kipsg. Lzuyamodo, xra jahd jpputovq af zi vayavju xwogu hezxsezisjuti UI lurnj zos sxa ojmfamewoaw’z yewk svenehow, iduv-mofizc hudjfzufs. Goveg im ghakt crem suprivogf besj jepibomb mekue ex xejbehawesk ifoz abgoyolvuin, yabc ut:
Otuy oeydoxjagituop (jezux, hanuec, kuvulcmehuaj)
Nako fupsodq sxaoxuud ig qotqobbyeez
U-zeypoqdo lsebciav uj gubtgworlooz jyajl
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.