What problem does it solve?
Swift Testing replaces XCTest with a macro-based approach, and it can be unclear how to define tests, assert results correctly, organize suites, parameterize cases, and migrate existing XCTest code.
Core Features & Use Cases
- Define tests with @Test: Create standalone or suite-contained tests using @Test, optionally customized with a display name and annotated concurrency/throws/availability.
- Organize tests with @Suite: Group related tests into suite types, apply suite traits, and understand constraints on suite types.
- Assert with #expect and #require: Validate outcomes and control whether the test continues after failures, including required unwrapping.
- Use parameterized tests: Generate multiple test cases from arrays, enum allCases, ranges, and zipped collections, with support for selectively re-running failing cases.
- Migrate from XCTest: Convert XCTest imports, test classes, setup/teardown, and assertions to the Swift Testing equivalents.
Quick Start
Ask the AI: “Show me how to migrate a simple XCTest test suite to Swift Testing using @Suite, @Test, #expect/#require, and parameterized test cases.”