swift-testing-expert
Installation
Summary
Write, review, and migrate Swift tests using modern Swift Testing APIs with parallel execution and clear diagnostics.
- Covers test structure,
#expect/#requiremacros, traits, tags, parameterized tests, and async waiting patterns for readable, maintainable tests - Guides incremental XCTest migration while preserving UI automation and performance-metric tests that require XCTest
- Prioritizes parallel-safe test design; recommends fixing shared state before applying
.serializedisolation - Includes flaky-test debugging, test-plan filtering by tags, and known-issue handling to reduce noise and improve CI signal
SKILL.md
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.