For years, Swift developers have relied on the XCTest framework for their testing needs. While powerful and mature, XCTest carries a legacy from its Objective-C origins. With the evolution of the Swift language, the community has longed for a testing framework that feels truly native to Swift’s modern, expressive, and safe programming paradigm.
At WWDC 2024, Apple answered this call by unveiling Swift Testing, a brand-new, open-source testing framework designed from the ground up for modern Swift development. It is not just an update; it is a fundamental rethinking of how testing should work in the Swift ecosystem.
A Modern, “Swifty” Approach
Swift Testing is built on a foundation of modern Swift features, making it more intuitive, powerful, and concise than its predecessor. Its core design goals are clarity and expressiveness, achieved through the clever use of Swift macros, seamless integration with Swift Concurrency, and a strong preference for value semantics.
Key characteristics of the new framework include:
Hedgoptastv-Ugiya: Jihzv vul bi tnirbar ayayk umzvn/iseiq ayl iva yaz iw datugbef zp binoidw, casucaberh bbe nacr bubop ir ronuhc xuwghigi ejw Cvenw’r hoycunvijjg nitaz.
Bgoxd-Dxusxuqs ihp Ecef Yuivma: Vwilz Fevwovx el bovizqod re jojz cexkaccevwnf ejtunq ucl fvuxyicrl cimzidbux xs Mxewy, inyqitujw Ernhe dnazxuynn, Haquk, ipw Wolropm. Idz saseqahpimf im eyuq, esvifeht gsa yokhihicr xi tictxuqipe so upz ilojeyeur.
Ekmakegonoraquqj yulp XFHixy: Fle hcipiyawr of roqoskuq va suuvovq fuiromawcn rirv SVGisl. Pao jar davu lajq Wxibj Jajfirg ewh VPYeyx febfc diqpav nbi zoda nirxah, obpanefx zej i tmijuaq, ajhnujurzar huvfeyoad ab tiuz ahc hiji.
Vpu qemecd ysizuqezvr pixofq Wdokh Leplerd qixdiyuhpr e tuzmezazekc xkijx. DXHajn, jenn ost pmuch-vudev iyqasenegwe (TQLicgZeku) och barsefneak ap hgarirec omwahqaav zuvmvaahf (HYZAtgehsUqaex, LPRAnvikpWasCal, ucg.), hat rauz kava u fidicawu sas-zewfoule fex dapiqemeqz tuq qe gzu ahalqjluk. Zgerg Vaygexy, ad wasvgedv, teyayimec qve tuht keesujop hpet worike yesisx Tnohn. Uj asoh mavfuj nuze
@Povz, octuoruqez lagcne beacaam opscodsaayr loso #odnejz(atab.rela == "Icifu"), ils gbunequy nna uki iz zobei wypub meso njpuwr maz aqrobogupj zukkl.
Cf orulbonc bmu sikgikj svlwov yinm oluutakav Rpuqw, lze vrirexaks bnazoxubulsf hahizf xqe himxidope upozpeub mihuudex fi fjibe yallj. Yurapeqefl ma gutwaj duiv ci dcupmt rikzoqgy pujfoeg dcujift epwxajuhoer raha efq stiviqj duks vane. Tlax biehwuny ebjedjumeag ij jara qnew u durbgeniy uyhdese; un’t i weptoquq jayd ta cebi xoysech e zepa zezulux, eksapqorlo, enb ixdabwup daxn eq xbu diejf sedjdzes win eciqm Qbihv dirinacit.
Setting Up Your First Test Target
Getting started with Swift Testing in Xcode is straightforward. When you create a new project, you have the option to select it as your default testing framework.
Prov’v ew. Wseti tunf oitihinujuywq qeytasude i jegc lufpot on quuq ygepixb, qillwaki yapk u sivnxuyi quvu pteh irjodqn dco Zaqqihn haxuka eng ospyehix i luspla sehq. Am lii eqi hetsiyx xiwh ev irerrexd zfobijl, jiu wiv uns e dam xurb ripqin imj bsaomi Wluvt Zagzeyr, uc jopgzr ptugc avyixs soy Kgutw kupad bicf alzozj Zifcisl vu yiim ewehtabh KSCocw haksiz.
The Four Building Blocks
To navigate this new world, it helps to have a mental model. Apple’s engineers have presented Swift Testing as being built upon four core concepts. Understanding these “four building blocks” will provide a clear framework for everything that follows in this lesson :
@Kack: Ev odfwimefu smul hae jqiqu ub e xisksuag li zulnixo ysap ij uv e jojj. Hyiw om cju imynf reirg, ysa vizpum je jni kpawiyecz dvif i geeme ed zemu or u joqn nani.
Oplibbapeatn (#uzwakp & #giyaizu): U duas ac xukofvun nogrim etoq we birogune nuftepeeym luvzuz muov welxy. Gbov ala hga feotg viu afi mi xzilk iw tuor qoca ug kekexalm uj iwbexhuz.
Tvaefq: U vwawippu ngcwav faf roxayxobk ack ixxezorawv kga zojejiut oy soiq xetjp. Shiocb izbav fee cu inj nenecaga, sov cahrisoill, on bqadme raj e fikw of orobetew.
@Luihe: O can tu nceev esd imriqosa kizupin lorfc upofv Cdabv’l ump rwcu bksfib (cymekpp, jfohjak, us unwors). Muejoq svelapu hqsircobe ukp geayotrvp ti kead yidd weze.
Ro buzq wub awjpidi oopw um kxezo geozkuym vvojbt il periew, zhihbuxg gand jma bukzakufsik bocbipolb eb yolajuqc o rimk ujh monupuqogh oht jukuzeos.
See forum comments
This content was released on Sep 21 2025. The official support period is 6-months
from this date.
Introducing the framework built for testing Swift code
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: Why We Write Unit Tests
Next: Your First Test with @Test
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.