
Swift Testing Expert
Steer your agent through Apple’s Swift Testing APIs, XCTest migration, and flaky async patterns while you ship iOS or macOS targets.
Overview
Swift Testing Expert is an agent skill most often used in Ship (also Build) that routes LLMs through Swift Testing patterns, async tests, and XCTest migration references for Apple platform codebases.
Install
npx skills add https://github.com/avdlee/swift-testing-agent-skill --skill swift-testing-expertWhat is this skill?
- Modular reference index: fundamentals, expectations, traits/tags, parameterization, parallelization
- Async/await testing, confirmations, and callback bridging guidance
- Dedicated XCTest → Swift Testing migration workflow
- Xcode navigator, insights, and diagnostics quality practices
- Performance and determinism section for parallel-safe, low-flake defaults
- 10 topical reference files in the skill index (fundamentals through Xcode workflows)
Adoption & trust: 3.3k installs on skills.sh; 406 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your agent writes XCTest-style or flaky async tests while you are trying to adopt Swift Testing and parallel-safe suites in Xcode.
Who is it for?
Indie iOS/macOS developers using agents to add or migrate tests alongside feature work in Xcode 16+ era projects.
Skip if: Pure Android/Kotlin stacks, backend-only teams with no Swift targets, or teams staying entirely on legacy XCTest without migration intent.
When should I use this skill?
Writing, organizing, migrating, or debugging Swift tests using Swift Testing APIs in Xcode-oriented Apple projects.
What do I get? / Deliverables
Tests and migrations follow indexed Swift Testing guidance—structured expectations, traits/tags, parameterization, and async confirmations—aligned with Xcode workflows.
- Swift Testing test suites with expectations and traits
- Migration steps from XCTest patterns
- Async and parameterized test implementations
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Automated test design and migration land in Ship as the canonical QA shelf, though you start adopting patterns during Build as features land. Testing subphase covers @Test suites, parameterized cases, parallelization, and Xcode workflows—not App Store listing work.
Where it fits
Convert legacy XCTest classes to @Test suites with traits for CI filtering.
Review a PR for missing #require on throwing paths and unsafe parallel shared state.
Scaffold parameterized UI logic tests while implementing a new SwiftUI feature module.
How it compares
Documentation router for Swift Testing authoring—not a test runner integration or CI MCP.
Common Questions / FAQ
Who is swift-testing-expert for?
Solo Apple-platform builders who want their coding agent to follow current Swift Testing docs instead of hallucinating XCTest APIs.
When should I use swift-testing-expert?
During Ship when adding suites, fixing flaky async tests, or migrating XCTest; during Build when scaffolding tests for new Swift modules.
Is swift-testing-expert safe to install?
It is read-only reference material; confirm trust via the Security Audits panel on this Prism page before installing from the repo.
SKILL.md
READMESKILL.md - Swift Testing Expert
# Swift Testing Reference Index - `fundamentals.md` - `@Test`, suites, structure, naming, and baseline patterns - `expectations.md` - `#expect`, `#require`, throw validation, and failure readability - `traits-and-tags.md` - traits, tags, bug linking, conditions, and test-plan filtering - `parameterized-testing.md` - single/multi-argument parameterization, `zip`, and scaling strategy - `parallelization-and-isolation.md` - default parallel execution, random order, `.serialized`, and isolation patterns - `performance-and-best-practices.md` - test speed, determinism, flaky-test prevention, and parallel-safe defaults - `async-testing-and-waiting.md` - async/await in tests, callback bridging, and event-stream verification - `migration-from-xctest.md` - pragmatic XCTest -> Swift Testing migration workflow - `xcode-workflows.md` - navigator/report workflows, insights, and diagnostics quality - `README.md` resources section - Apple documentation links for defining, organizing, and migrating tests # Async Testing and Waiting ## When to use this reference Use this file when tests involve async/await functions, completion handlers, streams/events, or timing-related flakiness. ## Preferred approach - Use async test functions and `await` naturally. - Keep async test code close to production async patterns. - Prefer structured concurrency patterns over ad-hoc synchronization. - Prefer confirmations for async event-style tests that are not naturally awaitable. ### Async function test example ```swift import Testing struct APIClient { func fetchName() async throws -> String { "Antoine" } } @Test func fetchNameReturnsValue() async throws { let client = APIClient() let value = try await client.fetchName() #expect(value == "Antoine") } ``` ## Callback bridging - For completion-handler APIs without async overloads, bridge with: - `withCheckedContinuation` - `withCheckedThrowingContinuation` - Keep continuation wrappers minimal and test-focused. ### Completion-handler to async bridge ```swift import Testing func legacyLoad(_ completion: @escaping (Result<Int, Error>) -> Void) { completion(.success(42)) } @Test func legacyAPI() async throws { let value = try await withCheckedThrowingContinuation { continuation in legacyLoad { result in continuation.resume(with: result) } } #expect(value == 42) } ``` ## Confirmations for asynchronous events - Use confirmations when validating event delivery/count semantics that do not map cleanly to direct `await`. - Set expected counts explicitly: - exact count for strict validation - lower-bounded range for at-least semantics - Keep confirmation scope small and ensure confirmations happen before the confirmation block returns. ### Confirmation example ```swift import Testing @Test func eventIsPublishedTwice() async { await confirmation("Publishes two events", expectedCount: 2) { confirm in confirm() confirm() } } ``` ## Event handlers and multi-fire callbacks - Avoid unsafe mutable shared counters from callback closures in strict concurrency mode. - Use isolation-safe patterns (actor state, AsyncSequence wrappers, or thread-safe containers). - Verify callback counts and ordering explicitly when behavior depends on it. ### Actor-isolated counting pattern ```swift import Testing actor EventCounter { private(set) var count = 0 func increment() { count += 1 } } @Test func countEventsSafely() async { let counter = EventCounter() await counter.increment() await counter.increment() #expect(await counter.count == 2) } ``` ## Avoid legacy waiting anti-patterns - Do not return from test before async callback work completes. - Avoid sleeping/time-based waits as primary synchronization. - Replace brittle waiting with awaitable conditions and deterministic synchronization points. ```swift // Avoid this pattern: // try await Task.sleep(nanoseconds: 500_000_000) // #expect(flag == true) ``` ## Actor isolation in tests - Isolate tests to a global actor (e.g. `@MainActor