swift-testing-expert

Write, migrate, and debug Swift Testing suites using #expect macros, traits, and parameterized tests.

1|Updated Aug 9, 2026
One-click install
npx skills add https://github.com/OMIXEC/all-in-one-swift-skills --skill swift-testing-expert-omixec
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: swift-testing-expert
Source: https://github.com/OMIXEC/all-in-one-swift-skills/tree/main/skills/swift-testing-expert
Command: npx skills add https://github.com/OMIXEC/all-in-one-swift-skills --skill swift-testing-expert-omixec

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Swift developers moving from XCTest to Swift Testing face unfamiliar macros, parallel-by-default execution that exposes flaky shared state, and uncertainty about which XCTest patterns still apply. This Skill provides structured guidance for writing modern Swift tests, migrating incrementally, and diagnosing flaky or slow test suites. ## Core Features & Use Cases - Assertion and macro guidance: Apply #expect for assertions, #require for preconditions, throw expectations, and withKnownIssue for temporary failures. - Suite organization: Structure tests with @Test, @Suite, traits, tags, and parameterized arguments, including safe alternatives to zip-based pairing. - Parallelization and migration: Design parallel-safe isolated tests, apply .serialized only as a transition step, bridge completion-handler APIs with continuations, and migrate XCTest suites incrementally. - Use Case: A team with a legacy XCTest suite wants to modernize. The Skill maps XCTAssert calls to #expect, converts repetitive test methods into parameterized @Test(arguments:) cases, and isolates shared database state so tests run safely in parallel on CI. ## Quick Start Ask the agent to review your Swift test file and convert XCTest assertions to Swift Testing with parameterized tests and proper traits.

Frequently Asked Questions about swift-testing-expert

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

FAQPage Schema
How do I migrate XCTest tests to Swift Testing?▼

Migrate incrementally: convert XCTAssert calls to #expect, replace XCTUnwrap with try #require, and turn test methods into @Test functions. XCTest and Swift Testing can coexist in the same target, so convert assertions first, then reorganize suites, then add parameterization and traits.

How do I write parameterized tests in Swift Testing?▼

Pass a sendable collection to @Test(arguments:) so each element becomes an independent test case. For paired inputs, prefer arrays of tuples or dictionaries over zip, since zip silently truncates mismatched lengths and breaks if CaseIterable ordering changes.

When should I use #require instead of #expect?▼

Use try #require when later assertions depend on a prerequisite value, such as unwrapping an optional. It fails the test early and returns the unwrapped value, while #expect records a failure and lets the test continue.

Why are my Swift Testing tests flaky in CI?▼

Swift Testing runs tests in parallel with randomized order, which exposes shared mutable state like globals and singletons. Fix flakiness by isolating state per test or using in-memory dependencies; apply .serialized only as a temporary transition measure.

Can Swift Testing and XCTest be used in the same target?▼

Yes, both frameworks coexist in one target and even one file can import both XCTest and Testing. Keep XCTest for UI automation with XCUIApplication, performance metrics with XCTMetric, and Objective-C-only tests, since Swift Testing does not cover those.

How do I test completion-handler APIs with Swift Testing?▼

Bridge completion handlers with withCheckedContinuation or withCheckedThrowingContinuation so the test can await the result. For event-style callbacks that are not naturally awaitable, use confirmations with an explicit expected count instead of sleeps.