swift-testing-expert
avdlee/swift-testing-agent-skill
Expert guidance for writing, migrating, and debugging Swift tests with modern Swift Testing APIs.
What is swift-testing-expert?
This skill provides comprehensive guidance for Swift Testing: test structure, assertions, traits, parameterized tests, parallel execution, async patterns, and XCTest migration. Use it when writing new Swift tests, modernizing XCTest suites, debugging flaky tests, or improving test quality in Apple-platform or Swift server projects.
- Write and organize Swift tests using modern Swift Testing APIs with clear structure and readable assertions
- Use #expect and #require macros correctly, with #require for prerequisites that block subsequent lines
- Design parameterized tests to replace repetitive test methods with shared logic and varied inputs
- Apply traits and tags for test behavior, metadata, filtering, and Xcode test-plan organization
- Debug flaky tests by identifying shared state, isolation issues, and unsafe parallel execution patterns
- Migrate incrementally from XCTest to Swift Testing while keeping UI automation and performance tests on XCTest
How to install swift-testing-expert
npx skills add https://github.com/avdlee/swift-testing-agent-skill --skill swift-testing-expertHow to use swift-testing-expert
- 1.Clarify your goal: new tests, migration, flaky failures, performance, or CI filtering
- 2.Collect facts about your Xcode/Swift version, current test framework (XCTest or Swift Testing), and whether failures are deterministic
- 3.Use the routing map to find the relevant reference section (fundamentals, expectations, traits, parameterization, parallelization, async, or migration)
- 4.Apply the guidance incrementally: convert assertions first, then organize suites, then introduce parameterization and traits
- 5.Verify your tests against the checklist: single clear behavior per test, prerequisites use #require, repeated logic is parameterized, tests are parallel-safe or intentionally serialized, async code is awaited
Use cases
- Writing new unit and integration tests for Swift apps and server projects using Swift Testing
- Converting existing XCTest suites to Swift Testing incrementally without breaking CI workflows
- Fixing flaky or non-deterministic test failures by improving isolation and parallel-safety
- Organizing large test suites with parameterization to reduce duplication and improve maintainability
- Filtering and organizing tests in Xcode using traits and tags instead of naming conventions
- Swift developers writing or maintaining unit and integration tests
- Teams migrating from XCTest to Swift Testing
- QA engineers debugging test flakiness and isolation issues
- iOS, macOS, watchOS, tvOS, and Swift server developers
swift-testing-expert FAQ
Migrate incrementally. Keep XCTest for UI automation (XCUIApplication), performance metrics (XCTMetric), and Objective-C-only test code. Convert unit and integration tests first by replacing assertions, then organizing suites and introducing parameterization.
Use #require when subsequent lines depend on a prerequisite value. If the test should stop and fail when a condition is not met, use #require. Otherwise, use #expect as the default assertion.
Default to parallel-safe guidance by fixing shared state first (databases, files, network, global state). Only use .serialized as a transition step. Isolate dependencies, use in-memory repositories, and ensure tests don't access shared resources.
Use parameterized tests with @Test(arguments:) to replace repetitive testFooCaseA/testFooCaseB methods. This reduces duplication and makes test logic clearer.
Use traits and tags to mark tests with metadata, then filter by tags in test plans. This is more maintainable than name-based filtering and works better with parameterized tests.
Full instructions (SKILL.md)
Source of truth, from avdlee/swift-testing-agent-skill.
name: swift-testing-expert description: 'Expert guidance for Swift Testing: test structure, #expect/#require macros, traits and tags, parameterized tests, test plans, parallel execution, async waiting patterns, and XCTest migration. Use when writing new Swift tests, modernizing XCTest suites, debugging flaky tests, or improving test quality and maintainability in Apple-platform or Swift server projects.'
Swift Testing
Overview
Use this skill to write, review, migrate, and debug Swift tests with modern Swift Testing APIs. Prioritize readable tests, robust parallel execution, clear diagnostics, and incremental migration from XCTest where needed.
Agent behavior contract (follow these rules)
- Prefer Swift Testing for Swift unit and integration tests, but keep XCTest for UI automation (
XCUIApplication), performance metrics (XCTMetric), and Objective-C-only test code. - Treat
#expectas the default assertion and use#requirewhen subsequent lines depend on a prerequisite value. - Default to parallel-safe guidance. If tests are not isolated, first propose fixing shared state before applying
.serialized. - Prefer traits for behavior and metadata (
.enabled,.disabled,.timeLimit,.bug, tags) over naming conventions or ad-hoc comments. - Recommend parameterized tests when multiple tests share logic and differ only in input values.
- Use
@availableon test functions for OS-gated behavior instead of runtime#availablechecks inside test bodies; never annotate suite types with@available. - Keep migration advice incremental: convert assertions first, then organize suites, then introduce parameterization/traits.
- Only import
Testingin test targets, never in app/library/binary targets.
First 60 seconds (triage template)
- Clarify the goal: new tests, migration, flaky failures, performance, CI filtering, or async waiting.
- Collect minimal facts:
- Xcode/Swift version and platform targets
- Whether tests currently use XCTest, Swift Testing, or both
- Whether failures are deterministic or flaky
- Whether tests access shared resources (database, files, network, global state)
- Branch quickly:
- repetitive tests -> parameterized tests
- noisy or flaky failures -> known issue handling and test isolation
- migration questions -> XCTest mapping and coexistence strategy
- async callback complexity -> continuation/await patterns
Routing map (read the right reference fast)
- Test building blocks and suite organization ->
references/fundamentals.md #expect,#require, and throw expectations ->references/expectations.md- Traits, tags, and Xcode test-plan filtering ->
references/traits-and-tags.md - Parameterized test design and combinatorics ->
references/parameterized-testing.md - Default parallel execution,
.serialized, isolation strategy ->references/parallelization-and-isolation.md - Test speed, determinism, and flakiness prevention ->
references/performance-and-best-practices.md - Async waiting and callback bridging ->
references/async-testing-and-waiting.md - XCTest coexistence and migration workflow ->
references/migration-from-xctest.md - Test navigator/report workflows and diagnostics ->
references/xcode-workflows.md - Index and quick navigation ->
references/_index.md
Common pitfalls -> next best move
- Repetitive
testFooCaseA/testFooCaseB/...methods -> replace with one parameterized@Test(arguments:). - Failing optional preconditions hidden in later assertions ->
try #require(...)then assert on unwrapped value. - Flaky integration tests on shared database -> isolate dependencies or in-memory repositories; use
.serializedonly as a transition step. - Disabled tests that silently rot -> prefer
withKnownIssuefor temporary known failures to preserve signal. - Unclear failure values for complex types -> conform type to
CustomTestStringConvertiblefor focused test diagnostics. - Test-plan include/exclude by names -> use tags and tag-based filters instead.
Verification checklist
- Confirm each test has a single clear behavior and expressive display name when needed.
- Confirm prerequisites use
#requirewhere failure should stop the test. - Confirm repeated logic is parameterized instead of duplicated.
- Confirm tests are parallel-safe or intentionally serialized with rationale.
- Confirm async code is awaited and callback APIs are bridged safely.
- Confirm migration keeps unsupported XCTest-only scenarios on XCTest.
References
references/_index.mdreferences/fundamentals.mdreferences/expectations.mdreferences/traits-and-tags.mdreferences/parameterized-testing.mdreferences/parallelization-and-isolation.mdreferences/performance-and-best-practices.mdreferences/async-testing-and-waiting.mdreferences/migration-from-xctest.mdreferences/xcode-workflows.md
Related skills
More from avdlee/swift-testing-agent-skill and the wider catalog.

find-skills
Discover and install agent skills to extend your coding agent's capabilities on demand

frontend-design
Build visually distinctive UI with opinionated aesthetic direction, typography, and layout choices that avoid templated defaults.

vercel-react-best-practices
70 React/Next.js performance rules from Vercel Engineering, prioritized by impact for writing, reviewing, and refactoring code.

agent-browser
Fast browser automation CLI for AI agents — navigate, click, scrape, screenshot, and test via Chrome CDP

web-design-guidelines
Review UI code against Web Interface Guidelines for accessibility, UX, and design best practices

finetuning
Fine-tune models on Azure AI Foundry with SFT, DPO, or RFT training methods.