talira

Swift Testing

Expressive and intuitive APIs that make testing your Swift code a breeze

open sourceApache-2.0 WITH Swift-exceptionself-hostablefree

Swift Testing is the modern testing library for Swift, built with macros: @Test marks a test, and #expect checks ordinary Swift expressions and captures the evaluated values, so a failure shows exactly what went wrong; #require stops a test when a precondition fails. Traits customize tests (conditions, OS versions, time limits), suites and tags organize them, tests can have descriptive names, and parameterized tests run the same test over many inputs. Tests integrate with Swift Concurrency and run in parallel by default. It's included in the official Swift toolchains for Apple platforms, Linux, FreeBSD and Windows (experimental on Android and Wasm), works in Xcode 16 and later and with swift test, runs alongside XCTest, and is Apache-2.0 licensed with the Swift runtime library exception.

Problems it solves

  • write unit tests in Swift with less boilerplate than XCTest
  • see the actual values when a Swift test assertion fails
  • run the same Swift test over many inputs with parameterized tests
  • run Swift tests in parallel and with async/await
  • skip or enable Swift tests based on conditions or OS versions
  • organize a large Swift test suite with tags and suites
  • test Swift code on Linux and Windows as well as Apple platforms

Features

  • @Test and @Suite macros
  • #expect and #require that capture evaluated values on failure
  • traits for conditions, OS versions and time limits
  • tags and test suites for organization
  • descriptive test names
  • parameterized tests
  • Swift Concurrency support and parallel execution by default
  • included in Swift toolchains: no package dependency needed
  • Apple platforms, Linux, FreeBSD and Windows; Android, Wasm and OpenBSD experimental
  • works alongside XCTest

Capabilities

Has official SDKsplan not known

Alternatives

The same job

These do what Swift Testing does.

  1. XCTest Create and run unit tests, performance tests, and UI tests for your Xcode project

Compare Swift Testing with the top 3