swift-testing

Migrate XCTest codebases to Swift Testing macros with @Test and #expect.

Updated May 6, 2026
One-click install
npx skills add https://github.com/Roy-wonji/claude-config --skill swift-testing-roy-wonji
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-testing
Source: https://github.com/Roy-wonji/claude-config/tree/main/skills/apple-skills/skills/swift-testing
Command: npx skills add https://github.com/Roy-wonji/claude-config --skill swift-testing-roy-wonji

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

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.”

Frequently Asked Questions about swift-testing

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

FAQPage Schema
How do I migrate XCTest test classes to Swift Testing?

Swift Testing replaces XCTest assertions with #expect and #require macros for validating outcomes. You use #expect to check conditions and continue on failure, while #require stops the test immediately if the condition fails.

How do I write parameterized tests in Swift Testing?

Swift Testing parameterized tests generate multiple cases from arrays, enum allCases, ranges, and zipped collections using @Test. This allows you to run the same logic across varied inputs and selectively re-run failing cases.

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

Swift Testing provides #expect and #require for assertions. The #expect macro validates outcomes and continues execution after failures, whereas #require stops the test immediately upon failure and handles required unwrapping.

How do I organize test suites using @Suite in Swift?

Swift Testing organizes related tests by grouping them into suite types with the @Suite macro. You can apply suite traits to these types to manage setup, teardown, and shared properties across contained @Test functions.

Can I use Swift Testing macros with async and throws functions?

Swift Testing macros support async and throws functions by annotating @Test with appropriate concurrency and availability traits. This ensures your tests correctly handle asynchronous code and error-throwing logic.