swift-testing

Write and migrate Swift unit and integration tests using Swift Testing framework.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/DFly7/iOS-FastAPI-Supabase-AI --skill swift-testing-dfly7
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-testing
Source: https://github.com/DFly7/iOS-FastAPI-Supabase-AI/tree/main/.agents/skills/swift-testing
Command: npx skills add https://github.com/DFly7/iOS-FastAPI-Supabase-AI --skill swift-testing-dfly7

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides a practical, opinionated reference for writing and migrating tests to the Swift Testing framework so teams can replace brittle XCTest patterns with composable, observable, and parameterized test suites that run reliably in CI and locally.

Core Features & Use Cases

  • Parameterized tests & generators: run argument collections, ranges, enums, cartesian products, and zipped inputs as separate test cases.
  • Assertions & control flow: use #expect for non-fatal checks and #require to assert and unwrap values needed for subsequent assertions.
  • Traits, tags, and suites: define reusable traits, tag tests for selective runs, and organize tests with @Suite including suite-level setup and teardown.
  • Async & concurrency patterns: confirmation-based async event testing, actor isolation handling, time limits, and programmatic cancellation.
  • Test doubles & architecture: protocol-based mocks, TestScoping fixtures, and patterns for testable dependency injection.
  • Migration & interoperability: guidance to convert XCTest UI/performance/snapshot tests to appropriate XCTest usage while using Swift Testing for unit and integration tests.
  • Attachments & exit testing: attach diagnostic data and capture exit/fatal scenarios for robust debugging.

Quick Start

Create a parameterized Swift Testing unit that uses @Test with arguments, asserts behavior with #expect, and applies a Tag to filter runs in CI.

Frequently Asked Questions about swift-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write parameterized tests in Swift Testing?

Swift Testing parameterized tests use the @Test macro with arguments to run collections, ranges, enums, cartesian products, and zipped inputs as separate test cases. This generates individual test coverage for each input without writing duplicate test functions.

What is the difference between #expect and #require in Swift Testing?

In Swift Testing, #expect performs non-fatal checks that allow a test to continue running, while #require asserts and unwraps values needed for subsequent assertions, failing the test immediately if the condition is not met.

Can I migrate XCTest unit tests to Swift Testing in Xcode 16+?

Yes, you can migrate XCTest unit and integration tests to Swift Testing in Xcode 16+ and Swift 6+ projects. The framework supports interoperability, allowing you to keep XCTest for UI and snapshot tests while adopting Swift Testing for unit suites.

How do I test asynchronous events with confirmations in Swift Testing?

Swift Testing handles asynchronous event testing using confirmation-based patterns. You configure confirmations within @Test functions to verify expected async events occur, alongside actor isolation handling, time limits, and programmatic cancellation.

What is the best way to organize Swift Testing suites and run selective tests?

Organize Swift Testing suites using the @Suite attribute with suite-level setup and teardown. Define reusable traits and tag tests to filter and run selective tests in CI, ensuring composable and observable test architecture.

Does Swift Testing support mocking and dependency injection?

Swift Testing supports protocol-based mocks and TestScoping fixtures to enable testable dependency injection. These test doubles allow you to isolate dependencies and verify interactions within your unit and integration test suites.