Portrait

I2H3

Notes from work as an app developer for iPhones, iPads and Macs.

RSS Icon GitHub Mastodon

Swift Testing

During WWDC24, Apple finally introduced a “swifty” test framework to replace XCTest.

I stumbled across it earlier this year on GitHub and already expected it becoming a thing being introduced during this WWDC. It looks very promising and finally like a real “swifty” alternative to XCTest. I like test traits in particular. Custom display names for tests, linking bugs and conditions are the most exciting ones.

a memoji

I want to highlight the .disabled(…) runtime condition for tests in particular. As explained in the video, it is superior to techniques like commenting out tests because the tests are still verified to compile. I have seen the practice of commenting out too often over the years and always critized it. Commented out code is not just dead but also litter in the repository which can be broken or obsolete since years without anyone noticing.

a memoji

Another great aspect is the gradual migration to Swift Testing. XCTest and Swift Testing implementations can coexist in the same test target.

See this session for further information: WWDC24: Meet Swift Testing.