Hey iOS developer! 👋
I’ve seen various opinions about testing Swift code - some say it’s useless, others insist we shouldn’t ship an app without 100% test coverage. As always, the truth lies somewhere in the middle.
But one thing is clear - we need tools that are modern and easy to use.
Last year, Apple introduced a new framework - Swift Testing. Let’s explore some great resources to help us get started with it.
Sponsor
Tart is a virtualization toolset to build, run and manage virtual machines
Test any version of macOS in seconds or integrate directly into your CI/CD pipeline for seamless upgrades.
Meet Swift Testing
A new set of tools introduced at WWDC24, designed to make testing Swift code easier and more flexible. This WWDC session covers the core concepts, shows how to customize tests, and demonstrates how to repeat them with different arguments.
Read on Apple Developer
Swift Testing basics explained
The Swift Testing framework promises a simpler and more modern alternative to XCTest. In this post, Donny Wals walks through the basics and shows how to get started with writing first tests.
Read on Donny Wals blog
How to get started with Swift Testing
In the next article, Vincent Pradeilles explores the main features of the Swift Testing and highlights how it differs from XCTest - including key improvements.
Read on Swift with Vincent
Migrating Tests from XCTest: A Comprehensive Guide
If you’re currently using XCTest in your project but want to migrate to Swift Testing, this detailed guide by Garrett Barker is a must-read. It covers a wide range of migration scenarios - from converting Test Classes to handling Asynchronous Tests.
Read on Medium
How to test completion handlers with Swift Testing and XCTest
Paul Hudson shares practical examples of how to test callback-based functions using both Swift Testing and XCTest - suited for working with older, non-async code.
Read on Hacking with Swift
Introducing Swift Testing. Scoping.
Test Scoping Traits, introduced in Swift 6.1, enables a Trait
-conforming type to provide a custom execution scope for test functions and suites, including running code before or after them.
Read on Swift with Majid
If you found this Curated iOS issue useful, I’d be happy if you:
Until next time!
Artjoms
Great selection of posts on the topic that is often overlooked