Here are some of the reasons why many developers are starting to prefer Swift Testing over XCTest:
1. The Syntax Just Flows Better
In XCTest, you’re constantly reaching for XCTAssertEqual
, XCTAssertTrue
, XCTAssertNil
, and so on. Each one has its own function, and you need to remember which is which.
In Swift Testing, you simply use #expect
with plain Swift expressions:
#expect(result == 42)
Compare that to:
XCTAssertEqual(result, 42)
Not a huge difference in one line, but when you multiply this across hundreds of tests, the Swift Testing style feels so much cleaner.
2. Failure Messages That Actually Help
One of the biggest frustrations with XCTest is its vague failure output. You’ll often see something like:
XCTAssertEqual failed: ("41") is not equal to ("42")
With Swift Testing, you get the exact expression and values spelled out in a way that makes debugging faster:
#expect(result == 42) failed – result was 41
It’s a small detail, but it makes a huge difference when you’re deep in test failures.
3. Async/Await Support That Feels Natural
XCTest bolted on async support later, so you still end up juggling expectation(description:)
and wait(for:)
in older tests.
Swift Testing was built with modern Swift in mind, so async tests just look like async functions. No hacks, no ceremony — just async
and await
like you’d expect.
4. No More Boilerplate
With XCTest, every test case lives inside a subclass of XCTestCase
. It works, but it’s a holdover from Objective-C days.
Swift Testing lets you just write test functions without the ceremony:
@Test func additionWorks() {
#expect(1 + 1 == 2)
}
That’s it. No subclassing, no overrides, no unnecessary setup.
5. It’s More than Just Apple
XCTest is tied tightly to Apple platforms. Swift Testing, on the other hand, is part of Swift’s open-source evolution. That means it’s designed to work not only in iOS and macOS apps but also on server-side Swift projects.
This makes it a much more future-friendly choice, especially if Swift keeps spreading beyond Apple’s ecosystem.
6. Community-Driven Future
Because Swift Testing lives in the open-source Swift project, it grows with community input. XCTest, by contrast, evolves mostly behind closed doors at Apple.
That means we’re likely to see Swift Testing improve rapidly in ways that reflect what developers actually want.
The Bottom Line
XCTest has served us well, but it carries a lot of baggage. Swift Testing feels lighter, more expressive, and better aligned with how we write Swift today.
- Less boilerplate
- More readable code
- Better failure messages
- Async-friendly out of the box
- Open-source and future-proof
If you’ve ever groaned while typing out yet another XCTAssertEqual
, give Swift Testing a try. You’ll probably never want to go back.