swift-testing

Installation
SKILL.md

Swift Testing Framework: Basics

Core Concepts

  • Import Testing to unlock macros; tests are plain functions annotated with @Test.
  • Name tests freely; XCTest's test name prefix has no meaning in Swift Testing. Use @Test("Display Name") to set the navigator title.
  • #expect is the primary assertion; pass it a boolean expression.
  • Assert one behaviour per test function; split a test that checks unrelated behaviours.
  • Mark the test function async/throws for async or throwing tests.
  • Swift Testing and XCTest run side by side in the same test target; a project that still holds XCTest tests is a supported end state.
  • When one change would be too large to review or bisect, convert an XCTest target in stages: give the staged order, one class or small batch per stage, and keep the target green between stages (principle-sequence-verifiable-units).
  • Swift Testing covers unit and integration tests but has no UI-automation or performance-measurement API. Keep XCUITest tests and XCTest measure performance tests on XCTest.

Example: Simple Test

import Testing

func add(_ a: Int, _ b: Int) -> Int { a + b }
Installs
16
Repository
mintuz/skills
GitHub Stars
29
First Seen
Jan 24, 2026