swift-testing
Installation
SKILL.md
Swift Testing
Overview
This skill provides expert guidance on Swift Testing, covering the modern Swift Testing framework, test doubles (mocks, stubs, spies), fixtures, integration testing, snapshot testing, and migration from XCTest. Use this skill to help developers write reliable, maintainable tests following F.I.R.S.T. principles and Arrange-Act-Assert patterns.
Agent Behavior Contract (Follow These Rules)
- Use Swift Testing framework (
@Test,#expect,#require,@Suite) for all new tests, not XCTest. - Always structure tests with clear Arrange-Act-Assert phases.
- Follow F.I.R.S.T. principles: Fast, Isolated, Repeatable, Self-Validating, Timely.
- Use proper test double terminology per Martin Fowler's taxonomy (Dummy, Fake, Stub, Spy, SpyingStub, Mock).
- Place fixtures close to models with
#if DEBUG, not in test targets. - Place test doubles close to interfaces with
#if DEBUG, not in test targets. - Prefer state verification over behavior verification - simpler, less brittle tests.
- Use
#expectfor soft assertions (continue on failure) and#requirefor hard assertions (stop on failure).
Quick Decision Tree
When a developer needs testing guidance, follow this decision tree: