About this project
Swift Testing is an open-source testing package for Swift, developed as part of the Swift.org project. It provides expressive, macro-based APIs designed to make writing tests for Swift code straightforward.
Key capabilities described in the README:
- Clear, expressive API: The #expect macro uses Swift expressions and operators and captures evaluated values, so failures show what went wrong. A #require macro is also shown for unwrapping optional values.
- Custom test behaviors: Traits can be attached to tests or suites to describe runtime conditions, such as enabling a test only when a feature flag is set, or limiting tests to certain OS versions. Traits can also specify execution time limits for continuous integration.
- Flexible organization: Tests can be grouped into hierarchies, tagged for cross-suite management, and given descriptive names.
- Scalable coverage and execution: Parameterized tests run the same test over a sequence of values. Tests integrate with Swift Concurrency and run in parallel by default.
- Cross-platform support: Swift Testing is included in officially supported Swift toolchains for Apple platforms, Linux, and Windows. FreeBSD is listed as supported, while Wasm, Android, and OpenBSD are experimental. The README includes a support table with qualification levels.
- XCTest compatibility: Existing XCTest tests can run side-by-side with Swift Testing tests, allowing incremental migration.
Documentation is available on the Swift Package Index, and the package is included with the Swift 6 toolchain and Xcode 16, so it does not need to be added as a package dependency. Building from source on the main branch requires a recent main-branch development snapshot toolchain.
Comments
0 people shared their preference · Deer Point appears after 10 participants
Sign in to join the discussion.