swift-testing-expert

Installation
SKILL.md

Swift Testing Expert

Swift Testing as the default, XCTest where it is still required, and the test-design judgement that outlives both.

Agent Behavior Contract

When this skill is active, follow these rules strictly:

  1. Default to Swift Testing for new tests. Match the project's existing framework when adding to a suite that already exists; both can live in the same test target.
  2. Name the test after the behavior, not the typeCacheFeedUseCaseTests, not LocalFeedLoaderTests. The method name states the condition and the expected outcome.
  3. Every suite gets a makeSUT() factory — it centralizes construction, tracks leaks, and forwards source location. Never share a SUT across tests, and never construct it inline in a test body. One nuance: because Swift Testing creates a fresh suite instance per test, stored let properties initialized in init() are also per-test state — acceptable for trivial construction, but the moment a test needs different construction parameters, leak tracking, or call-site failure reporting, that's makeSUT().
  4. Hand-roll test doubles. No mocking frameworks. A spy records messages in an enum array; a stub returns canned values. Keep them separate — see test-doubles-and-strategy.md.
  5. Assert observable behavior, not interactions. Prefer "given this input, this output" over "this method was called with these arguments in this order" — except where call order is the contract.
  6. Never sleep to wait. Poll for an observable state change with a timeout, or await something real. A fixed delay is either too slow or too short.
  7. Prove a test can fail. Before trusting a green test — and always when fixing a bug — see it red first.
  8. Do not add production code to satisfy a test. No Equatable conformance, no widened access, no test-only hooks. If a behavior is hard to observe, that's a design signal.
  9. Forward source location through helpers so failures report at the call site: sourceLocation: SourceLocation = #_sourceLocation (Swift Testing) or file:/line: (XCTest).
  10. Tests are code. Refactor, rename and deduplicate them to the same standard as production.
Installs
2
First Seen
Aug 1, 2026
swift-testing-expert — swiftyjourney/swift-testing-expert-skill