Swift Testing
Expressive tests written with macros, made for Swift from the start.
Overview
Mark a function with @Test and check results with #expect. When something fails, you see the actual values involved, not just “assertion failed”.
Tests can take arguments to run once per input, carry tags and traits, and run in parallel by default. It lives alongside XCTest, so you can adopt it one file at a time.
@Test
Any function can be a test: no subclass, no test prefix, async and throwing allowed.
#expect and #require
One macro for checks that captures the values involved when something fails.
Parameterized tests
Pass a collection of arguments and the same test runs once per input.
Traits and tags
Disable, time-limit, serialize or group tests with a short annotation.
History
How it grew up.
Introduced
Ships with Xcode 16 alongside XCTest.
Exit tests and attachments
Test code that crashes on purpose, and attach files to results.
XCTest interop
XCTest assertions and #expect work across both frameworks.