ワンクリックで
swift-testing-pro
Use when writing tests with the Swift Testing framework (@Test,
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when writing tests with the Swift Testing framework (@Test,
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when writing, reviewing, or refactoring SwiftUI code — covers modern state management (@Observable), NavigationStack, layout, performance, and accessibility for iOS 26 / Swift 6.
Use when adding App Intents — exposing app actions to Siri, Shortcuts, and Spotlight with AppIntent, parameters, AppEntity, and App Shortcuts.
Use when working with Core Data — modeling entities, NSPersistentContainer setup, background contexts, fetch requests, batch operations, and migrations.
Use when making SwiftUI/UIKit apps accessible — VoiceOver labels and traits, Dynamic Type, color contrast, Reduce Motion, and accessibility testing.
Use when structuring an iOS app — feature modularization, MVVM with @Observable, dependency injection, navigation routing, and layering for testability.
Use when writing or reviewing core Swift — choosing value vs reference types, handling optionals, error handling, generics, protocols, and following Swift API design guidelines.
| name | swift-testing-pro |
| description | Use when writing tests with the Swift Testing framework (@Test, |
| license | MIT |
| metadata | {"author":"Lax Rajpurohit","version":"1.0.0"} |
Write clear, fast tests with the Swift Testing framework. Prefer it over XCTest for new code.
Trigger: /swift-testing-pro.
@Test functions, not test-prefixed XCTestCase methods.#expect for soft assertions; #require to stop the test on failure.@Suite (struct/actor) — a fresh instance per test gives isolation.async/throws directly; no expectation-fulfillment dance.❌ XCTest
import XCTest
final class MathTests: XCTestCase {
func testAdd() { XCTAssertEqual(add(2, 3), 5) }
}
✅ Swift Testing
import Testing
@Test func add() {
#expect(add(2, 3) == 5)
}
#expect(x == y) records a failure but continues.try #require(value) unwraps/asserts and halts the test if it fails — use before
dereferencing.✅
@Test func parsesUser() throws {
let user = try #require(User(json: sample)) // stop if nil
#expect(user.name == "Ada")
}
@Suite struct CartTests {
let cart = Cart() // fresh per test — no shared state
@Test func startsEmpty() { #expect(cart.items.isEmpty) }
@Test func addsItem() {
cart.add(.sample)
#expect(cart.items.count == 1)
}
}
Don't reuse mutable state across tests (no XCTest setUp shared singletons).
Replace copy-pasted near-identical tests with arguments:.
❌
@Test func evenTwo() { #expect(isEven(2)) }
@Test func evenFour() { #expect(isEven(4)) }
✅
@Test(arguments: [2, 4, 100])
func even(_ n: Int) { #expect(isEven(n)) }
Cross-product with multiple arguments: collections; use zip for paired inputs.
@Test func loadsFeed() async throws {
let feed = try await api.feed()
#expect(!feed.isEmpty)
}
@Test func throwsOnBadInput() {
#expect(throws: ParseError.self) {
try parse("")
}
}
.tags(.network) to group/filter..enabled(if:) / .disabled("reason") to gate..timeLimit(.minutes(1)) for runaway protection..bug("JIRA-123") to link issues.@Test(.disabled("flaky on CI — FIX-42"))
func flakyThing() { ... }
Prefer .disabled("reason") over commenting tests out — it stays visible and tracked.
XCTestCase for new tests.#expect before a force-unwrap that should be try #require.arguments: parameterized..disabled("reason").XCTestExpectation where plain async/await works.Per issue: file:line, rule, before/after. Flag missing coverage of error paths and edge cases.