
- Installs
- 205
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/johnrogers/claude-swift-engineering --skill swift-testing- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads swift-testing automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Swift Testing Framework
Modern testing with Swift Testing framework. No XCTest.
Overview
Swift Testing replaces XCTest with a modern macro-based approach that's more concise, has better async support, and runs tests in parallel by default. The core principle: if you learned XCTest, unlearn it—Swift Testing works differently.
References
Core Concepts
Assertions
| Macro | Use Case |
|---|---|
#expect(expression) | Soft check — continues on failure. Use for most assertions. |
#require(expression) | Hard check — stops test on failure. Use for preconditions only. |
Optional Unwrapping
let user = try #require(await fetchUser(id: "123"))
#expect(user.id == "123")
Test Structure
import Testing
@testable import YourModule
@Suite
struct FeatureTests {
let sut: FeatureType
init() throws {
sut = FeatureType()
}
@Test("Description of behavior")
func testBehavior() {
#expect(sut.someProperty == expected)
}
}
Assertion Conversions
| XCTest | Swift Testing |
|---|---|
XCTAssert(expr) | #expect(expr) |
XCTAssertEqual(a, b) | #expect(a == b) |
XCTAssertNil(a) | #expect(a == nil) |
XCTAssertNotNil(a) | #expect(a != nil) |
try XCTUnwrap(a) | try #require(a) |
XCTAssertThrowsError | #expect(throws: ErrorType.self) { } |
XCTAssertNoThrow | #expect(throws: Never.self) { } |
Error Testing
#expect(throws: (any Error).self) { try riskyOperation() }
#expect(throws: NetworkError.self) { try fetch() }
#expect(throws: NetworkError.timeout) { try fetch() }
#expect(throws: Never.self) { try safeOperation() }
Parameterized Tests
@Test("Validates inputs", arguments: zip(
["a", "b", "c"],
[1, 2, 3]
))
func testInputs(input: String, expected: Int) {
#expect(process(input) == expected)
}
Warning: Multiple collections WITHOUT zip creates Cartesian product.
Async Testing
@Test func testAsync() async throws {
let result = try await fetchData()
#expect(!result.isEmpty)
}
Confirmations
@Test func testCallback() async {
await confirmation("callback received") { confirm in
let sut = SomeType { confirm() }
sut.triggerCallback()
}
}
Tags
extension Tag {
@Tag static var fast: Self
@Tag static var networking: Self
}
@Test(.tags(.fast, .networking))
func testNetworkCall() { }
Common Pitfalls
- Overusing
#require— Use#expectfor most checks - Forgetting state isolation — Each test gets a NEW instance
- Accidental Cartesian product — Always use
zipfor paired inputs - Not using
.serialized— Apply for thread-unsafe legacy tests
Common Mistakes
-
Overusing
#require—#requireis for preconditions only. Using it for normal assertions means the test stops at first failure instead of reporting all failures. Use#expectfor assertions,#requireonly when subsequent assertions depend on the value. -
Cartesian product bugs —
@Test(arguments: [a, b], [c, d])creates 4 combinations, not 2. Always usezipto pair arguments correctly:arguments: zip([a, b], [c, d]). -
Forgetting state isolation — Swift Testing creates a new test instance per test method. BUT shared state between tests (static variables, singletons) still leak. Use dependency injection or clean up singletons between tests.
-
Parallel test conflicts — Swift Testing runs tests in parallel by default. Tests touching shared files, databases, or singletons will interfere. Use
.serializedor isolation strategies. -
Not using
asyncnaturally — Wrapping async operations inTask { }defeats the purpose. Useasync/awaitdirectly in test function signature:@Test func testAsync() async throws { }. -
Confirmation misuse —
confirmationis for verifying callbacks were called. Using it for assertions is wrong. Use#expectfor assertions,confirmationfor callback counts.
FAQ
What does the swift-testing skill do?
Use when writing tests with Swift Testing (@Test,
How do I install swift-testing?
Run npx skills add https://github.com/johnrogers/claude-swift-engineering --skill swift-testing in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/swift-testing/ (personal) or .claude/skills/swift-testing/ (project).
Which AI agents can use swift-testing?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is swift-testing safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains swift-testing?
It is published by johnrogers in johnrogers/claude-swift-engineering. It has 205 recorded installs.
More from johnrogers/claude-swift-engineering
swift-style
johnrogers/claude-swift-engineering
Swift code style conventions for clean, readable code. Use when writing Swift code to ensure consistent formatting, naming, organization, and idiomatic patterns.
ios-hig
johnrogers/claude-swift-engineering
Open the skill to read its SKILL.md instructions.
swiftui-patterns
johnrogers/claude-swift-engineering
Open the skill to read its SKILL.md instructions.
ios-26-platform
johnrogers/claude-swift-engineering
Open the skill to read its SKILL.md instructions.
composable-architecture
johnrogers/claude-swift-engineering
Open the skill to read its SKILL.md instructions.
sqlite-data
johnrogers/claude-swift-engineering
Open the skill to read its SKILL.md instructions.
Popular testing & qa skills
tdd
mattpocock/skills
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
grilling
mattpocock/skills
Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
migrate-to-shoehorn
mattpocock/skills
Migrate test files from as type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace as in tests, or needs partial test data.
run-train
lllllllama/rigorpilot-skills
Rigor Train skill for deep learning research repositories. Use when a documented or selected training command should be run conservatively for startup verification, short-run verification, full kickoff, or resume, with command, config, seed, log, checkpoint, status, and metric evidence written to standardized trainoutputs/. Do not use for environment setup, exploratory sweeps, speculative idea implementation, or end-to-end orchestration.
test-driven-development
obra/superpowers
Use when implementing any feature or bugfix, before writing implementation code
finishing-a-development-branch
obra/superpowers
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work