[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6E6Q9BD3XF6MB9V2Q06T85G":3,"skill-same:01M6E6Q9BD3XF6MB9V2Q06T85G":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":50,"ownerHtmlUrl":51,"ownerBlogUrl":6,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M6E6Q9BD3XF6MB9V2Q06T85G","axiom-swift-testing",null,"Use when writing unit tests, adopting Swift Testing framework, making tests run faster without simulator, architecting code for testability, testing async code reliably, or migrating from XCTest - covers @Test\u002F@Suite macros,","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FCharlesWiltgen\u002FAxiom\u002Faxiom-swift-testing\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"axiom swift testing","swift","testing","swift testing","use","unit","testability","tests","macros","tests run","async","testing framework","framework","code","run","unit tests","test","writing","2026-11-10 10:12:30",false,"---\nname: axiom-swift-testing\ndescription: Use when writing unit tests, adopting Swift Testing framework, making tests run faster without simulator, architecting code for testability, testing async code reliably, or migrating from XCTest - covers @Test\u002F@Suite macros, #expect\u002F#require, parameterized tests, traits, tags, parallel execution, host-less testing\nlicense: MIT\nmetadata:\n  version: \"1.0.0\"\n  last-updated: \"WWDC 2024 (Swift Testing framework)\"\n---\n\n# Swift Testing\n\n## Overview\n\nSwift Testing is Apple's modern testing framework introduced at WWDC 2024. It uses Swift macros (`@Test`, `#expect`) instead of naming conventions, runs tests in parallel by default, and integrates seamlessly with Swift concurrency.\n\n**Core principle**: Tests should be fast, reliable, and expressive. The fastest tests run without launching your app or simulator.\n\n## The Speed Hierarchy\n\nTests run at dramatically different speeds depending on how they're configured:\n\n| Configuration | Typical Time | Use Case |\n|---------------|--------------|----------|\n| `swift test` (Package) | ~0.1s | Pure logic, models, algorithms |\n| Host Application: None | ~3s | Framework code, no UI dependencies |\n| Bypass app launch | ~6s | App target but skip initialization |\n| Full app launch | 20-60s | UI tests, integration tests |\n\n**Key insight**: Move testable logic into Swift Packages or frameworks, then test with `swift test` or \"None\" host application.\n\n---\n\n## Building Blocks\n\n### @Test Functions\n\n```swift\nimport Testing\n\n@Test func videoHasCorrectMetadata() {\n    let video = Video(named: \"example.mp4\")\n    #expect(video.duration == 120)\n}\n```\n\n**Key differences from XCTest**:\n- No `test` prefix required — `@Test` attribute is explicit\n- Can be global functions, not just methods in a class\n- Supports `async`, `throws`, and actor isolation\n- Each test runs on a fresh instance of its containing suite\n\n### #expect and #require\n\n```swift\n\u002F\u002F Basic expectation — test continues on failure\n#expect(result == expected)\n#expect(array.isEmpty)\n#expect(numbers.contains(42))\n\n\u002F\u002F Required expectation — test stops on failure\nlet user = try #require(await fetchUser(id: 123))\n#expect(user.name == \"Alice\")\n\n\u002F\u002F Unwrap optionals safely\nlet first = try #require(items.first)\n#expect(first.isValid)\n```\n\n**Why #expect is better than XCTAssert**:\n- Captures source code and sub-values automatically\n- Single macro handles all operators (==, >, contains, etc.)\n- No need for specialized assertions (XCTAssertEqual, XCTAssertNil, etc.)\n\n### Error Testing\n\n```swift\n\u002F\u002F Expect any error\n#expect(throws: (any Error).self) {\n    try dangerousOperation()\n}\n\n\u002F\u002F Expect specific error type\n#expect(throws: NetworkError.self) {\n    try fetchData()\n}\n\n\u002F\u002F Expect specific error value\n#expect(throws: ValidationError.invalidEmail) {\n    try validate(email: \"not-an-email\")\n}\n\n\u002F\u002F Custom validation\n#expect {\n    try process(data)\n} throws: { error in\n    guard let networkError = error as? NetworkError else { return false }\n    return networkError.statusCode == 404\n}\n```\n\n### @Suite Types\n\n```swift\n@Suite(\"Video Processing Tests\")\nstruct VideoTests {\n    let video = Video(named: \"sample.mp4\")  \u002F\u002F Fresh instance per test\n\n    @Test func hasCorrectDuration() {\n        #expect(video.duration == 120)\n    }\n\n    @Test func hasCorrectResolution() {\n        #expect(video.resolution == CGSize(width: 1920, height: 1080))\n    }\n}\n```\n\n**Key behaviors**:\n- Structs preferred (value semantics, no accidental state sharing)\n- Each `@Test` gets its own suite instance\n- Use `init` for setup, `deinit` for teardown (actors\u002Fclasses only)\n- Nested suites supported for organization\n\n---\n\n## Traits\n\nTraits customize test behavior:\n\n```swift\n\u002F\u002F Display name\n@Test(\"User can log in with valid credentials\")\nfunc loginWithValidCredentials() { }\n\n\u002F\u002F Disable with reason\n@Test(.disabled(\"Waiting for backend fix\"))\nfunc brokenFeature() { }\n\n\u002F\u002F Conditional execution\n@Test(.enabled(if: FeatureFlags.newUIEnabled))\nfunc newUITest() { }\n\n\u002F\u002F Time limit\n@Test(.timeLimit(.minutes(1)))\nfunc longRunningTest() async { }\n\n\u002F\u002F Bug reference\n@Test(.bug(\"https:\u002F\u002Fgithub.com\u002Forg\u002Frepo\u002Fissues\u002F123\", \"Flaky on CI\"))\nfunc sometimesFailingTest() { }\n\n\u002F\u002F OS version requirement\n@available(iOS 18, *)\n@Test func iOS18OnlyFeature() { }\n```\n\n### Tags for Organization\n\n```swift\n\u002F\u002F Define tags\nextension Tag {\n    @Tag static var networking: Self\n    @Tag static var performance: Self\n    @Tag static var slow: Self\n}\n\n\u002F\u002F Apply to tests\n@Test(.tags(.networking, .slow))\nfunc networkIntegrationTest() async { }\n\n\u002F\u002F Apply to entire suite\n@Suite(.tags(.performance))\nstruct PerformanceTests {\n    @Test func benchmarkSort() { }  \u002F\u002F Inherits .performance tag\n}\n```\n\n**Use tags to**:\n- Run subsets of tests (filter by tag in Test Navigator)\n- Exclude slow tests from quick feedback loops\n- Group related tests across different files\u002Fsuites\n\n---\n\n## Parameterized Testing\n\nTransform repetitive tests into a single parameterized test:\n\n```swift\n\u002F\u002F ❌ Before: Repetitive\n@Test func vanillaHasNoNuts() {\n    #expect(!IceCream.vanilla.containsNuts)\n}\n@Test func chocolateHasNoNuts() {\n    #expect(!IceCream.chocolate.containsNuts)\n}\n@Test func almondHasNuts() {\n    #expect(IceCream.almond.containsNuts)\n}\n\n\u002F\u002F ✅ After: Parameterized\n@Test(arguments: [IceCream.vanilla, .chocolate, .strawberry])\nfunc flavorWithoutNuts(_ flavor: IceCream) {\n    #expect(!flavor.containsNuts)\n}\n\n@Test(arguments: [IceCream.almond, .pistachio])\nfunc flavorWithNuts(_ flavor: IceCream) {\n    #expect(flavor.containsNuts)\n}\n```\n\n### Two-Collection Parameterization\n\n```swift\n\u002F\u002F Test all combinations (4 × 3 = 12 test cases)\n@Test(arguments: [1, 2, 3, 4], [\"a\", \"b\", \"c\"])\nfunc allCombinations(number: Int, letter: String) {\n    \u002F\u002F Tests: (1,\"a\"), (1,\"b\"), (1,\"c\"), (2,\"a\"), ...\n}\n\n\u002F\u002F Test paired values only (3 test cases)\n@Test(arguments: zip([1, 2, 3], [\"one\", \"two\", \"three\"]))\nfunc pairedValues(number: Int, name: String) {\n    \u002F\u002F Tests: (1,\"one\"), (2,\"two\"), (3,\"three\")\n}\n```\n\n### Benefits Over For-Loops\n\n| For-Loop | Parameterized |\n|----------|---------------|\n| Stops on first failure | All arguments run |\n| Unclear which value failed | Each argument shown separately |\n| Sequential execution | Parallel execution |\n| Can't re-run single case | Re-run individual arguments |\n\n---\n\n## Fast Tests: Architecture for Testability\n\n### Strategy 1: Swift Package for Logic (Fastest)\n\nExtract app logic into a Swift Package. Tests run with `swift test` (~0.4s) instead of `xcodebuild test` (~25s) — no simulator, no app launch. This is the key enabler for TDD in Claude Code hooks.\n\n#### Step 1: Create Package.swift\n\nCreate the package directory alongside your `.xcodeproj`:\n\n```swift\n\u002F\u002F MyAppCore\u002FPackage.swift\n\u002F\u002F swift-tools-version: 6.0\nimport PackageDescription\n\nlet package = Package(\n    name: \"MyAppCore\",\n    platforms: [.iOS(.v18), .macOS(.v15)],\n    products: [\n        .library(name: \"MyAppCore\", targets: [\"MyAppCore\"]),\n    ],\n    targets: [\n        .target(name: \"MyAppCore\"),\n        .testTarget(name: \"MyAppCoreTests\", dependencies: [\"MyAppCore\"]),\n    ]\n)\n```\n\n#### Step 2: Link Package to App\n\nCreate an `.xcworkspace` containing both the app project and the package:\n1. File → New → Workspace\n2. Drag your `.xcodeproj` into the workspace\n3. File → Add Package Dependencies → Add Local → select `MyAppCore\u002F`\n4. Add `MyAppCore` framework to your app target's \"Frameworks, Libraries, and Embedded Content\"\n\n#### Step 3: Move Logic, Expose Root View\n\nMove models, services, and view models into `MyAppCore\u002FSources\u002FMyAppCore\u002F`. Types used by the app must be `public`. Create a public root view that accepts dependencies via injection:\n\n```swift\n\u002F\u002F In MyAppCore\npublic struct MyAppRootView: View {\n    @State private var appState: AppStateController\n\n    public init(modelContainer: ModelContainer) {\n        _appState = State(initialValue: AppStateController(container: modelContainer))\n    }\n\n    public var body: some View { \u002F* ... *\u002F }\n}\n```\n\n#### Step 4: Thin-Shell App.swift\n\nThe app target becomes a thin shell that imports the package and delegates (see `axiom-app-composition` for the full thin-shell principle):\n\n```swift\nimport SwiftUI\nimport MyAppCore\n\n@main\nstruct MyApp: App {\n    let container = try! ModelContainer(for: \u002F* schemas *\u002F)\n\n    var body: some Scene {\n        WindowGroup {\n            MyAppRootView(modelContainer: container)\n        }\n    }\n}\n```\n\n#### What Stays vs What Moves\n\n| Stays in App Target | Moves to Package |\n|---------------------|------------------|\n| `@main` App.swift (thin shell) | Models, view models, services |\n| Asset catalogs, resources | Business logic, algorithms |\n| Info.plist, entitlements | Navigation, state management |\n| Launch screen | Utilities, extensions |\n\nTests use `@testable import MyAppCore` for internal access.\n\n#### Running Tests\n\n```bash\ncd MyAppCore\nswift test                              # All tests (~0.4s)\nswift test --filter MyAppCoreTests.UserTests  # Single suite\n```\n\nFor project-level scripts separating unit from UI tests:\n\n```bash\n# script\u002Ftest\n#!\u002Fbin\u002Fbash\ncase \"${1:-unit}\" in\n    unit) cd MyAppCore && swift test ;;\n    ui)   xcodebuild test -workspace MyApp.xcworkspace \\\n            -scheme MyApp -destination 'platform=iOS Simulator,name=iPhone 16' ;;\nesac\n```\n\n#### Progressive Extraction for Existing Projects\n\nFor apps that can't extract everything at once, move modules incrementally:\n\n#### Phase 1: Leaf Modules First\nStart with code that has no dependencies on the app target:\n- Data models and DTOs\n- Networking layer (API clients, request builders)\n- Business logic and validation rules\n- Utility extensions\n\n#### Phase 2: Break Circular Dependencies\nIf package code needs to call back into app-owned types:\n1. Define a protocol in the package (the package owns the abstraction)\n2. Inject a conforming implementation from the app target at startup\n3. Move the implementation into the package once all its dependencies are in the package\n\n#### Phase 3: Maintain Both Test Targets\nDuring transition, keep two test targets:\n- `MyAppCoreTests` — runs with `swift test` (extracted logic)\n- `MyAppTests` — runs with `xcodebuild test` (remaining app-level tests)\n\nGradually migrate tests from `MyAppTests` to `MyAppCoreTests` as you extract their source files.\n\n**Goal**: Each extraction should leave the app building and all tests passing. Never extract more than one module boundary at a time.\n\n### Strategy 2: Framework with No Host Application\n\nFor code that must stay in the app project:\n\n1. **Create a framework target** (File → New → Target → Framework)\n2. **Move model code** into the framework\n3. **Make types public** that need external access\n4. **Add imports** in files using the framework\n5. **Set Host Application to \"None\"** in test target settings\n\n```\nProject Settings → Test Target → Testing\n  Host Application: None  ← Key setting\n  ☐ Allow testing Host Application APIs\n```\n\nBuild+test time: ~3 seconds vs 20-60 seconds with app launch.\n\n### Strategy 3: Bypass SwiftUI App Launch\n\nIf you can't use a framework, bypass the app launch:\n\n```swift\n\u002F\u002F Simple solution (no custom startup code)\n@main\nstruct ProductionApp: App {\n    var body: some Scene {\n        WindowGroup {\n            if !isRunningTests {\n                ContentView()\n            }\n        }\n    }\n\n    private var isRunningTests: Bool {\n        NSClassFromString(\"XCTestCase\") != nil\n    }\n}\n```\n\n```swift\n\u002F\u002F Thorough solution (custom startup code)\n@main\nstruct MainEntryPoint {\n    static func main() {\n        if NSClassFromString(\"XCTestCase\") != nil {\n            TestApp.main()  \u002F\u002F Empty app for tests\n        } else {\n            ProductionApp.main()\n        }\n    }\n}\n\nstruct TestApp: App {\n    var body: some Scene {\n        WindowGroup { }  \u002F\u002F Empty\n    }\n}\n```\n\n---\n\n## Async Testing\n\n### Basic Async Tests\n\n```swift\n@Test func fetchUserReturnsData() async throws {\n    let user = try await userService.fetch(id: 123)\n    #expect(user.name == \"Alice\")\n}\n```\n\n### Testing Callbacks with Continuations\n\n```swift\n\u002F\u002F Convert completion handler to async\n@Test func legacyAPIWorks() async throws {\n    let result = try await withCheckedThrowingContinuation { continuation in\n        legacyService.fetchData { result in\n            continuation.resume(with: result)\n        }\n    }\n    #expect(result.count > 0)\n}\n```\n\n### Confirmations for Multiple Events\n\n```swift\n@Test func cookiesAreEaten() async {\n    await confirmation(\"cookie eaten\", expectedCount: 10) { confirm in\n        let jar = CookieJar(count: 10)\n        jar.onCookieEaten = { confirm() }\n        await jar.eatAll()\n    }\n}\n\n\u002F\u002F Confirm something never happens\nawait confirmation(expectedCount: 0) { confirm in\n    let cache = Cache()\n    cache.onEviction = { confirm() }\n    cache.store(\"small-item\")  \u002F\u002F Should not trigger eviction\n}\n```\n\n### Reliable Async Testing with Concurrency Extras\n\n**Problem**: Async tests can be flaky due to scheduling unpredictability.\n\n```swift\n\u002F\u002F ❌ Flaky: Task scheduling is unpredictable\n@Test func loadingStateChanges() async {\n    let model = ViewModel()\n    let task = Task { await model.loadData() }\n    #expect(model.isLoading == true)  \u002F\u002F Often fails!\n    await task.value\n}\n```\n\n**Solution**: Use Point-Free's `swift-concurrency-extras`:\n\n```swift\nimport ConcurrencyExtras\n\n@Test func loadingStateChanges() async {\n    await withMainSerialExecutor {\n        let model = ViewModel()\n        let task = Task { await model.loadData() }\n        await Task.yield()\n        #expect(model.isLoading == true)  \u002F\u002F Deterministic!\n        await task.value\n        #expect(model.isLoading == false)\n    }\n}\n```\n\n**Why it works**: Serializes async work to main thread, making suspension points deterministic.\n\n### Deterministic Time with TestClock\n\nUse Point-Free's `swift-clocks` to control time in tests:\n\n```swift\nimport Clocks\n\n@MainActor\nclass FeatureModel: ObservableObject {\n    @Published var count = 0\n    let clock: any Clock\u003CDuration>\n    var timerTask: Task\u003CVoid, Error>?\n\n    init(clock: any Clock\u003CDuration>) {\n        self.clock = clock\n    }\n\n    func startTimer() {\n        timerTask = Task {\n            while true {\n                try await clock.sleep(for: .seconds(1))\n                count += 1\n            }\n        }\n    }\n}\n\n\u002F\u002F Test with controlled time\n@Test func timerIncrements() async {\n    let clock = TestClock()\n    let model = FeatureModel(clock: clock)\n\n    model.startTimer()\n\n    await clock.advance(by: .seconds(1))\n    #expect(model.count == 1)\n\n    await clock.advance(by: .seconds(4))\n    #expect(model.count == 5)\n\n    model.timerTask?.cancel()\n}\n```\n\n**Clock types**:\n- `TestClock` — Advance time manually, deterministic\n- `ImmediateClock` — All sleeps return instantly (great for previews)\n- `UnimplementedClock` — Fails if used (catch unexpected time dependencies)\n\n---\n\n## Parallel Testing\n\nSwift Testing runs tests in parallel by default.\n\n### When to Serialize\n\n```swift\n\u002F\u002F Serialize tests in a suite that share external state\n@Suite(.serialized)\nstruct DatabaseTests {\n    @Test func createUser() { }\n    @Test func deleteUser() { }  \u002F\u002F Runs after createUser\n}\n\n\u002F\u002F Serialize parameterized test cases\n@Test(.serialized, arguments: [1, 2, 3])\nfunc sequentialProcessing(value: Int) { }\n```\n\n### Hidden Dependencies\n\n```swift\n\u002F\u002F ❌ Bug: Tests depend on execution order\n@Suite struct CookieTests {\n    static var cookie: Cookie?\n\n    @Test func bakeCookie() {\n        Self.cookie = Cookie()  \u002F\u002F Sets shared state\n    }\n\n    @Test func eatCookie() {\n        #expect(Self.cookie != nil)  \u002F\u002F Fails if runs first!\n    }\n}\n\n\u002F\u002F ✅ Fixed: Each test is independent\n@Suite struct CookieTests {\n    @Test func bakeCookie() {\n        let cookie = Cookie()\n        #expect(cookie.isBaked)\n    }\n\n    @Test func eatCookie() {\n        let cookie = Cookie()\n        cookie.eat()\n        #expect(cookie.isEaten)\n    }\n}\n```\n\n**Random order** helps expose these bugs — fix them rather than serialize.\n\n---\n\n## Known Issues\n\nHandle expected failures without noise:\n\n```swift\n@Test func featureUnderDevelopment() {\n    withKnownIssue(\"Backend not ready yet\") {\n        try callUnfinishedAPI()\n    }\n}\n\n\u002F\u002F Conditional known issue\n@Test func platformSpecificBug() {\n    withKnownIssue(\"Fails on iOS 17.0\") {\n        try reproduceEdgeCaseBug()\n    } when: {\n        ProcessInfo().operatingSystemVersion.majorVersion == 17\n    }\n}\n```\n\n**Better than .disabled because**:\n- Test still compiles (catches syntax errors)\n- You're notified when the issue is fixed\n- Results show \"expected failure\" not \"skipped\"\n\n---\n\n## Migration from XCTest\n\n### Comparison Table\n\n| XCTest | Swift Testing |\n|--------|---------------|\n| `func testFoo()` | `@Test func foo()` |\n| `XCTAssertEqual(a, b)` | `#expect(a == b)` |\n| `XCTAssertNil(x)` | `#expect(x == nil)` |\n| `XCTAssertThrowsError` | `#expect(throws:)` |\n| `XCTUnwrap(x)` | `try #require(x)` |\n| `class FooTests: XCTestCase` | `@Suite struct FooTests` |\n| `setUp()` \u002F `tearDown()` | `init` \u002F `deinit` |\n| `continueAfterFailure = false` | `#require` (per-expectation) |\n| `addTeardownBlock` | `deinit` or defer |\n\n### Keep Using XCTest For\n\n- **UI tests** (XCUIApplication)\n- **Performance tests** (XCTMetric)\n- **Objective-C tests**\n\n### Migration Tips\n\n1. Both frameworks can coexist in the same target\n2. Migrate incrementally, one test file at a time\n3. Consolidate similar XCTests into parameterized Swift tests\n4. Single-test XCTestCase → global `@Test` function\n\n---\n\n## Common Mistakes\n\n### ❌ Mixing Assertions\n\n```swift\n\u002F\u002F Don't mix XCTest and Swift Testing\n@Test func badExample() {\n    XCTAssertEqual(1, 1)  \u002F\u002F ❌ Wrong framework\n    #expect(1 == 1)       \u002F\u002F ✅ Use this\n}\n```\n\n### ❌ Using Classes for Suites\n\n```swift\n\u002F\u002F ❌ Avoid: Reference semantics can cause shared state bugs\n@Suite class VideoTests { }\n\n\u002F\u002F ✅ Prefer: Value semantics isolate each test\n@Suite struct VideoTests { }\n```\n\n### ❌ Forgetting @MainActor\n\n```swift\n\u002F\u002F ❌ May fail with Swift 6 strict concurrency\n@Test func updateUI() async {\n    viewModel.updateTitle(\"New\")  \u002F\u002F Data race warning\n}\n\n\u002F\u002F ✅ Isolate to main actor\n@Test @MainActor func updateUI() async {\n    viewModel.updateTitle(\"New\")\n}\n```\n\n### ❌ Over-Serializing\n\n```swift\n\u002F\u002F ❌ Don't serialize just because tests use async\n@Suite(.serialized) struct APITests { }  \u002F\u002F Defeats parallelism\n\n\u002F\u002F ✅ Only serialize when tests truly share mutable state\n```\n\n### ❌ XCTestCase with Swift 6.2 MainActor Default\n\nSwift 6.2's `default-actor-isolation = MainActor` breaks XCTestCase:\n\n```swift\n\u002F\u002F ❌ Error: Main actor-isolated initializer 'init()' has different\n\u002F\u002F actor isolation from nonisolated overridden declaration\nfinal class PlaygroundTests: XCTestCase {\n    override func setUp() async throws {\n        try await super.setUp()\n    }\n}\n```\n\n**Solution**: Mark XCTestCase subclass as `nonisolated`:\n\n```swift\n\u002F\u002F ✅ Works with MainActor default isolation\nnonisolated final class PlaygroundTests: XCTestCase {\n    @MainActor\n    override func setUp() async throws {\n        try await super.setUp()\n    }\n\n    @Test @MainActor\n    func testSomething() async {\n        \u002F\u002F Individual tests can be @MainActor\n    }\n}\n```\n\n**Why**: XCTestCase is Objective-C, not annotated for Swift concurrency. Its initializers are `nonisolated`, causing conflicts with MainActor-isolated subclasses.\n\n**Better solution**: Migrate to Swift Testing (`@Suite struct`) which handles isolation properly.\n\n---\n\n## Xcode Optimization for Fast Feedback\n\n### Turn Off Parallel XCTest Execution\n\nSwift Testing runs in parallel by default; XCTest parallelization adds overhead:\n\n```\nTest Plan → Options → Parallelization → \"Swift Testing Only\"\n```\n\n### Turn Off Test Debugger\n\nAttaching the debugger costs ~1 second per run:\n\n```\nScheme → Edit Scheme → Test → Info → ☐ Debugger\n```\n\n### Delete UI Test Templates\n\nXcode's default UI tests slow everything down. Remove them:\n1. Delete UI test target (Project Settings → select target → -)\n2. Delete UI test source folder\n\n### Disable dSYM for Debug Builds\n\n```\nBuild Settings → Debug Information Format\n  Debug: DWARF\n  Release: DWARF with dSYM File\n```\n\n### Check Build Scripts\n\nRun Script phases without defined inputs\u002Foutputs cause full rebuilds. Always specify:\n- Input Files \u002F Input File Lists\n- Output Files \u002F Output File Lists\n\n---\n\n## Checklist\n\n### Before Writing Tests\n- [ ] Identify what can move to a Swift Package (pure logic)\n- [ ] Set up framework target if package isn't viable\n- [ ] Configure Host Application: None for unit tests\n\n### Writing Tests\n- [ ] Use `@Test` with clear display names\n- [ ] Use `#expect` for all assertions\n- [ ] Use `#require` to fail fast on preconditions\n- [ ] Use parameterization for similar test cases\n- [ ] Add `.tags()` for organization\n\n### Async Tests\n- [ ] Mark test functions `async` and use `await`\n- [ ] Use `confirmation()` for callback-based code\n- [ ] Consider `withMainSerialExecutor` for flaky tests\n\n### Parallel Safety\n- [ ] Avoid shared mutable state between tests\n- [ ] Use fresh instances in each test\n- [ ] Only use `.serialized` when absolutely necessary\n\n---\n\n## Resources\n\n**WWDC**: 2024-10179, 2024-10195\n\n**Docs**: \u002Ftesting, \u002Ftesting\u002Fmigratingfromxctest, \u002Ftesting\u002Ftesting-asynchronous-code, \u002Ftesting\u002Fparallelization\n\n**GitHub**: pointfreeco\u002Fswift-concurrency-extras, pointfreeco\u002Fswift-clocks\n\n---\n\n**History:** See git log for changes\n\n","# Swift Testing\n\n## Overview\n\nSwift Testing is Apple's modern testing framework introduced at WWDC 2024. It uses Swift macros (`@Test`, `#expect`) instead of naming conventions, runs tests in parallel by default, and integrates seamlessly with Swift concurrency.\n\n**Core principle**: Tests should be fast, reliable, and expressive. The fastest tests run without launching your app or simulator.\n\n## The Speed Hierarchy\n\nTests run at dramatically different speeds depending on how they're configured:\n\n| Configuration | Typical Time | Use Case |\n|---------------|--------------|----------|\n| `swift test` (Package) | ~0.1s | Pure logic, models, algorithms |\n| Host Application: None | ~3s | Framework code, no UI dependencies |\n| Bypass app launch | ~6s | App target but skip initialization |\n| Full app launch | 20-60s | UI tests, integration tests |\n\n**Key insight**: Move testable logic into Swift Packages or frameworks, then test with `swift test` or \"None\" host application.\n\n---\n\n## Building Blocks\n\n### @Test Functions\n\n```swift\nimport Testing\n\n@Test func videoHasCorrectMetadata() {\n    let video = Video(named: \"example.mp4\")\n    #expect(video.duration == 120)\n}\n```\n\n**Key differences from XCTest**:\n- No `test` prefix required — `@Test` attribute is explicit\n- Can be global functions, not just methods in a class\n- Supports `async`, `throws`, and actor isolation\n- Each test runs on a fresh instance of its containing suite\n\n### #expect and #require\n\n```swift\n\u002F\u002F Basic expectation — test continues on failure\n#expect(result == expected)\n#expect(array.isEmpty)\n#expect(numbers.contains(42))\n\n\u002F\u002F Required expectation — test stops on failure\nlet user = try #require(await fetchUser(id: 123))\n#expect(user.name == \"Alice\")\n\n\u002F\u002F Unwrap optionals safely\nlet first = try #require(items.first)\n#expect(first.isValid)\n```\n\n**Why #expect is better than XCTAssert**:\n- Captures source code and sub-values automatically\n- Single macro handles all operators (==, >, contains, etc.)\n- No need for specialized assertions (XCTAssertEqual, XCTAssertNil, etc.)\n\n### Error Testing\n\n```swift\n\u002F\u002F Expect any error\n#expect(throws: (any Error).self) {\n    try dangerousOperation()\n}\n\n\u002F\u002F Expect specific error type\n#expect(throws: NetworkError.self) {\n    try fetchData()\n}\n\n\u002F\u002F Expect specific error value\n#expect(throws: ValidationError.invalidEmail) {\n    try validate(email: \"not-an-email\")\n}\n\n\u002F\u002F Custom validation\n#expect {\n    try process(data)\n} throws: { error in\n    guard let networkError = error as? NetworkError else { return false }\n    return networkError.statusCode == 404\n}\n```\n\n### @Suite Types\n\n```swift\n@Suite(\"Video Processing Tests\")\nstruct VideoTests {\n    let video = Video(named: \"sample.mp4\")  \u002F\u002F Fresh instance per test\n\n    @Test func hasCorrectDuration() {\n        #expect(video.duration == 120)\n    }\n\n    @Test func hasCorrectResolution() {\n        #expect(video.resolution == CGSize(width: 1920, height: 1080))\n    }\n}\n```\n\n**Key behaviors**:\n- Structs preferred (value semantics, no accidental state sharing)\n- Each `@Test` gets its own suite instance\n- Use `init` for setup, `deinit` for teardown (actors\u002Fclasses only)\n- Nested suites supported for organization\n\n---\n\n## Traits\n\nTraits customize test behavior:\n\n```swift\n\u002F\u002F Display name\n@Test(\"User can log in with valid credentials\")\nfunc loginWithValidCredentials() { }\n\n\u002F\u002F Disable with reason\n@Test(.disabled(\"Waiting for backend fix\"))\nfunc brokenFeature() { }\n\n\u002F\u002F Conditional execution\n@Test(.enabled(if: FeatureFlags.newUIEnabled))\nfunc newUITest() { }\n\n\u002F\u002F Time limit\n@Test(.timeLimit(.minutes(1)))\nfunc longRunningTest() async { }\n\n\u002F\u002F Bug reference\n@Test(.bug(\"https:\u002F\u002Fgithub.com\u002Forg\u002Frepo\u002Fissues\u002F123\", \"Flaky on CI\"))\nfunc sometimesFailingTest() { }\n\n\u002F\u002F OS version requirement\n@available(iOS 18, *)\n@Test func iOS18OnlyFeature() { }\n```\n\n### Tags for Organization\n\n```swift\n\u002F\u002F Define tags\nextension Tag {\n    @Tag static var networking: Self\n    @Tag static var performance: Self\n    @Tag static var slow: Self\n}\n\n\u002F\u002F Apply to tests\n@Test(.tags(.networking, .slow))\nfunc networkIntegrationTest() async { }\n\n\u002F\u002F Apply to entire suite\n@Suite(.tags(.performance))\nstruct PerformanceTests {\n    @Test func benchmarkSort() { }  \u002F\u002F Inherits .performance tag\n}\n```\n\n**Use tags to**:\n- Run subsets of tests (filter by tag in Test Navigator)\n- Exclude slow tests from quick feedback loops\n- Group related tests across different files\u002Fsuites\n\n---\n\n## Parameterized Testing\n\nTransform repetitive tests into a single parameterized test:\n\n```swift\n\u002F\u002F ❌ Before: Repetitive\n@Test func vanillaHasNoNuts() {\n    #expect(!IceCream.vanilla.containsNuts)\n}\n@Test func chocolateHasNoNuts() {\n    #expect(!IceCream.chocolate.containsNuts)\n}\n@Test func almondHasNuts() {\n    #expect(IceCream.almond.containsNuts)\n}\n\n\u002F\u002F ✅ After: Parameterized\n@Test(arguments: [IceCream.vanilla, .chocolate, .strawberry])\nfunc flavorWithoutNuts(_ flavor: IceCream) {\n    #expect(!flavor.containsNuts)\n}\n\n@Test(arguments: [IceCream.almond, .pistachio])\nfunc flavorWithNuts(_ flavor: IceCream) {\n    #expect(flavor.containsNuts)\n}\n```\n\n### Two-Collection Parameterization\n\n```swift\n\u002F\u002F Test all combinations (4 × 3 = 12 test cases)\n@Test(arguments: [1, 2, 3, 4], [\"a\", \"b\", \"c\"])\nfunc allCombinations(number: Int, letter: String) {\n    \u002F\u002F Tests: (1,\"a\"), (1,\"b\"), (1,\"c\"), (2,\"a\"), ...\n}\n\n\u002F\u002F Test paired values only (3 test cases)\n@Test(arguments: zip([1, 2, 3], [\"one\", \"two\", \"three\"]))\nfunc pairedValues(number: Int, name: String) {\n    \u002F\u002F Tests: (1,\"one\"), (2,\"two\"), (3,\"three\")\n}\n```\n\n### Benefits Over For-Loops\n\n| For-Loop | Parameterized |\n|----------|---------------|\n| Stops on first failure | All arguments run |\n| Unclear which value failed | Each argument shown separately |\n| Sequential execution | Parallel execution |\n| Can't re-run single case | Re-run individual arguments |\n\n---\n\n## Fast Tests: Architecture for Testability\n\n### Strategy 1: Swift Package for Logic (Fastest)\n\nExtract app logic into a Swift Package. Tests run with `swift test` (~0.4s) instead of `xcodebuild test` (~25s) — no simulator, no app launch. This is the key enabler for TDD in Claude Code hooks.\n\n#### Step 1: Create Package.swift\n\nCreate the package directory alongside your `.xcodeproj`:\n\n```swift\n\u002F\u002F MyAppCore\u002FPackage.swift\n\u002F\u002F swift-tools-version: 6.0\nimport PackageDescription\n\nlet package = Package(\n    name: \"MyAppCore\",\n    platforms: [.iOS(.v18), .macOS(.v15)],\n    products: [\n        .library(name: \"MyAppCore\", targets: [\"MyAppCore\"]),\n    ],\n    targets: [\n        .target(name: \"MyAppCore\"),\n        .testTarget(name: \"MyAppCoreTests\", dependencies: [\"MyAppCore\"]),\n    ]\n)\n```\n\n#### Step 2: Link Package to App\n\nCreate an `.xcworkspace` containing both the app project and the package:\n1. File → New → Workspace\n2. Drag your `.xcodeproj` into the workspace\n3. File → Add Package Dependencies → Add Local → select `MyAppCore\u002F`\n4. Add `MyAppCore` framework to your app target's \"Frameworks, Libraries, and Embedded Content\"\n\n#### Step 3: Move Logic, Expose Root View\n\nMove models, services, and view models into `MyAppCore\u002FSources\u002FMyAppCore\u002F`. Types used by the app must be `public`. Create a public root view that accepts dependencies via injection:\n\n```swift\n\u002F\u002F In MyAppCore\npublic struct MyAppRootView: View {\n    @State private var appState: AppStateController\n\n    public init(modelContainer: ModelContainer) {\n        _appState = State(initialValue: AppStateController(container: modelContainer))\n    }\n\n    public var body: some View { \u002F* ... *\u002F }\n}\n```\n\n#### Step 4: Thin-Shell App.swift\n\nThe app target becomes a thin shell that imports the package and delegates (see `axiom-app-composition` for the full thin-shell principle):\n\n```swift\nimport SwiftUI\nimport MyAppCore\n\n@main\nstruct MyApp: App {\n    let container = try! ModelContainer(for: \u002F* schemas *\u002F)\n\n    var body: some Scene {\n        WindowGroup {\n            MyAppRootView(modelContainer: container)\n        }\n    }\n}\n```\n\n#### What Stays vs What Moves\n\n| Stays in App Target | Moves to Package |\n|---------------------|------------------|\n| `@main` App.swift (thin shell) | Models, view models, services |\n| Asset catalogs, resources | Business logic, algorithms |\n| Info.plist, entitlements | Navigation, state management |\n| Launch screen | Utilities, extensions |\n\nTests use `@testable import MyAppCore` for internal access.\n\n#### Running Tests\n\n```bash\ncd MyAppCore\nswift test                              # All tests (~0.4s)\nswift test --filter MyAppCoreTests.UserTests  # Single suite\n```\n\nFor project-level scripts separating unit from UI tests:\n\n```bash\n# script\u002Ftest\n#!\u002Fbin\u002Fbash\ncase \"${1:-unit}\" in\n    unit) cd MyAppCore && swift test ;;\n    ui)   xcodebuild test -workspace MyApp.xcworkspace \\\n            -scheme MyApp -destination 'platform=iOS Simulator,name=iPhone 16' ;;\nesac\n```\n\n#### Progressive Extraction for Existing Projects\n\nFor apps that can't extract everything at once, move modules incrementally:\n\n#### Phase 1: Leaf Modules First\nStart with code that has no dependencies on the app target:\n- Data models and DTOs\n- Networking layer (API clients, request builders)\n- Business logic and validation rules\n- Utility extensions\n\n#### Phase 2: Break Circular Dependencies\nIf package code needs to call back into app-owned types:\n1. Define a protocol in the package (the package owns the abstraction)\n2. Inject a conforming implementation from the app target at startup\n3. Move the implementation into the package once all its dependencies are in the package\n\n#### Phase 3: Maintain Both Test Targets\nDuring transition, keep two test targets:\n- `MyAppCoreTests` — runs with `swift test` (extracted logic)\n- `MyAppTests` — runs with `xcodebuild test` (remaining app-level tests)\n\nGradually migrate tests from `MyAppTests` to `MyAppCoreTests` as you extract their source files.\n\n**Goal**: Each extraction should leave the app building and all tests passing. Never extract more than one module boundary at a time.\n\n### Strategy 2: Framework with No Host Application\n\nFor code that must stay in the app project:\n\n1. **Create a framework target** (File → New → Target → Framework)\n2. **Move model code** into the framework\n3. **Make types public** that need external access\n4. **Add imports** in files using the framework\n5. **Set Host Application to \"None\"** in test target settings\n\n```\nProject Settings → Test Target → Testing\n  Host Application: None  ← Key setting\n  ☐ Allow testing Host Application APIs\n```\n\nBuild+test time: ~3 seconds vs 20-60 seconds with app launch.\n\n### Strategy 3: Bypass SwiftUI App Launch\n\nIf you can't use a framework, bypass the app launch:\n\n```swift\n\u002F\u002F Simple solution (no custom startup code)\n@main\nstruct ProductionApp: App {\n    var body: some Scene {\n        WindowGroup {\n            if !isRunningTests {\n                ContentView()\n            }\n        }\n    }\n\n    private var isRunningTests: Bool {\n        NSClassFromString(\"XCTestCase\") != nil\n    }\n}\n```\n\n```swift\n\u002F\u002F Thorough solution (custom startup code)\n@main\nstruct MainEntryPoint {\n    static func main() {\n        if NSClassFromString(\"XCTestCase\") != nil {\n            TestApp.main()  \u002F\u002F Empty app for tests\n        } else {\n            ProductionApp.main()\n        }\n    }\n}\n\nstruct TestApp: App {\n    var body: some Scene {\n        WindowGroup { }  \u002F\u002F Empty\n    }\n}\n```\n\n---\n\n## Async Testing\n\n### Basic Async Tests\n\n```swift\n@Test func fetchUserReturnsData() async throws {\n    let user = try await userService.fetch(id: 123)\n    #expect(user.name == \"Alice\")\n}\n```\n\n### Testing Callbacks with Continuations\n\n```swift\n\u002F\u002F Convert completion handler to async\n@Test func legacyAPIWorks() async throws {\n    let result = try await withCheckedThrowingContinuation { continuation in\n        legacyService.fetchData { result in\n            continuation.resume(with: result)\n        }\n    }\n    #expect(result.count > 0)\n}\n```\n\n### Confirmations for Multiple Events\n\n```swift\n@Test func cookiesAreEaten() async {\n    await confirmation(\"cookie eaten\", expectedCount: 10) { confirm in\n        let jar = CookieJar(count: 10)\n        jar.onCookieEaten = { confirm() }\n        await jar.eatAll()\n    }\n}\n\n\u002F\u002F Confirm something never happens\nawait confirmation(expectedCount: 0) { confirm in\n    let cache = Cache()\n    cache.onEviction = { confirm() }\n    cache.store(\"small-item\")  \u002F\u002F Should not trigger eviction\n}\n```\n\n### Reliable Async Testing with Concurrency Extras\n\n**Problem**: Async tests can be flaky due to scheduling unpredictability.\n\n```swift\n\u002F\u002F ❌ Flaky: Task scheduling is unpredictable\n@Test func loadingStateChanges() async {\n    let model = ViewModel()\n    let task = Task { await model.loadData() }\n    #expect(model.isLoading == true)  \u002F\u002F Often fails!\n    await task.value\n}\n```\n\n**Solution**: Use Point-Free's `swift-concurrency-extras`:\n\n```swift\nimport ConcurrencyExtras\n\n@Test func loadingStateChanges() async {\n    await withMainSerialExecutor {\n        let model = ViewModel()\n        let task = Task { await model.loadData() }\n        await Task.yield()\n        #expect(model.isLoading == true)  \u002F\u002F Deterministic!\n        await task.value\n        #expect(model.isLoading == false)\n    }\n}\n```\n\n**Why it works**: Serializes async work to main thread, making suspension points deterministic.\n\n### Deterministic Time with TestClock\n\nUse Point-Free's `swift-clocks` to control time in tests:\n\n```swift\nimport Clocks\n\n@MainActor\nclass FeatureModel: ObservableObject {\n    @Published var count = 0\n    let clock: any Clock\u003CDuration>\n    var timerTask: Task\u003CVoid, Error>?\n\n    init(clock: any Clock\u003CDuration>) {\n        self.clock = clock\n    }\n\n    func startTimer() {\n        timerTask = Task {\n            while true {\n                try await clock.sleep(for: .seconds(1))\n                count += 1\n            }\n        }\n    }\n}\n\n\u002F\u002F Test with controlled time\n@Test func timerIncrements() async {\n    let clock = TestClock()\n    let model = FeatureModel(clock: clock)\n\n    model.startTimer()\n\n    await clock.advance(by: .seconds(1))\n    #expect(model.count == 1)\n\n    await clock.advance(by: .seconds(4))\n    #expect(model.count == 5)\n\n    model.timerTask?.cancel()\n}\n```\n\n**Clock types**:\n- `TestClock` — Advance time manually, deterministic\n- `ImmediateClock` — All sleeps return instantly (great for previews)\n- `UnimplementedClock` — Fails if used (catch unexpected time dependencies)\n\n---\n\n## Parallel Testing\n\nSwift Testing runs tests in parallel by default.\n\n### When to Serialize\n\n```swift\n\u002F\u002F Serialize tests in a suite that share external state\n@Suite(.serialized)\nstruct DatabaseTests {\n    @Test func createUser() { }\n    @Test func deleteUser() { }  \u002F\u002F Runs after createUser\n}\n\n\u002F\u002F Serialize parameterized test cases\n@Test(.serialized, arguments: [1, 2, 3])\nfunc sequentialProcessing(value: Int) { }\n```\n\n### Hidden Dependencies\n\n```swift\n\u002F\u002F ❌ Bug: Tests depend on execution order\n@Suite struct CookieTests {\n    static var cookie: Cookie?\n\n    @Test func bakeCookie() {\n        Self.cookie = Cookie()  \u002F\u002F Sets shared state\n    }\n\n    @Test func eatCookie() {\n        #expect(Self.cookie != nil)  \u002F\u002F Fails if runs first!\n    }\n}\n\n\u002F\u002F ✅ Fixed: Each test is independent\n@Suite struct CookieTests {\n    @Test func bakeCookie() {\n        let cookie = Cookie()\n        #expect(cookie.isBaked)\n    }\n\n    @Test func eatCookie() {\n        let cookie = Cookie()\n        cookie.eat()\n        #expect(cookie.isEaten)\n    }\n}\n```\n\n**Random order** helps expose these bugs — fix them rather than serialize.\n\n---\n\n## Known Issues\n\nHandle expected failures without noise:\n\n```swift\n@Test func featureUnderDevelopment() {\n    withKnownIssue(\"Backend not ready yet\") {\n        try callUnfinishedAPI()\n    }\n}\n\n\u002F\u002F Conditional known issue\n@Test func platformSpecificBug() {\n    withKnownIssue(\"Fails on iOS 17.0\") {\n        try reproduceEdgeCaseBug()\n    } when: {\n        ProcessInfo().operatingSystemVersion.majorVersion == 17\n    }\n}\n```\n\n**Better than .disabled because**:\n- Test still compiles (catches syntax errors)\n- You're notified when the issue is fixed\n- Results show \"expected failure\" not \"skipped\"\n\n---\n\n## Migration from XCTest\n\n### Comparison Table\n\n| XCTest | Swift Testing |\n|--------|---------------|\n| `func testFoo()` | `@Test func foo()` |\n| `XCTAssertEqual(a, b)` | `#expect(a == b)` |\n| `XCTAssertNil(x)` | `#expect(x == nil)` |\n| `XCTAssertThrowsError` | `#expect(throws:)` |\n| `XCTUnwrap(x)` | `try #require(x)` |\n| `class FooTests: XCTestCase` | `@Suite struct FooTests` |\n| `setUp()` \u002F `tearDown()` | `init` \u002F `deinit` |\n| `continueAfterFailure = false` | `#require` (per-expectation) |\n| `addTeardownBlock` | `deinit` or defer |\n\n### Keep Using XCTest For\n\n- **UI tests** (XCUIApplication)\n- **Performance tests** (XCTMetric)\n- **Objective-C tests**\n\n### Migration Tips\n\n1. Both frameworks can coexist in the same target\n2. Migrate incrementally, one test file at a time\n3. Consolidate similar XCTests into parameterized Swift tests\n4. Single-test XCTestCase → global `@Test` function\n\n---\n\n## Common Mistakes\n\n### ❌ Mixing Assertions\n\n```swift\n\u002F\u002F Don't mix XCTest and Swift Testing\n@Test func badExample() {\n    XCTAssertEqual(1, 1)  \u002F\u002F ❌ Wrong framework\n    #expect(1 == 1)       \u002F\u002F ✅ Use this\n}\n```\n\n### ❌ Using Classes for Suites\n\n```swift\n\u002F\u002F ❌ Avoid: Reference semantics can cause shared state bugs\n@Suite class VideoTests { }\n\n\u002F\u002F ✅ Prefer: Value semantics isolate each test\n@Suite struct VideoTests { }\n```\n\n### ❌ Forgetting @MainActor\n\n```swift\n\u002F\u002F ❌ May fail with Swift 6 strict concurrency\n@Test func updateUI() async {\n    viewModel.updateTitle(\"New\")  \u002F\u002F Data race warning\n}\n\n\u002F\u002F ✅ Isolate to main actor\n@Test @MainActor func updateUI() async {\n    viewModel.updateTitle(\"New\")\n}\n```\n\n### ❌ Over-Serializing\n\n```swift\n\u002F\u002F ❌ Don't serialize just because tests use async\n@Suite(.serialized) struct APITests { }  \u002F\u002F Defeats parallelism\n\n\u002F\u002F ✅ Only serialize when tests truly share mutable state\n```\n\n### ❌ XCTestCase with Swift 6.2 MainActor Default\n\nSwift 6.2's `default-actor-isolation = MainActor` breaks XCTestCase:\n\n```swift\n\u002F\u002F ❌ Error: Main actor-isolated initializer 'init()' has different\n\u002F\u002F actor isolation from nonisolated overridden declaration\nfinal class PlaygroundTests: XCTestCase {\n    override func setUp() async throws {\n        try await super.setUp()\n    }\n}\n```\n\n**Solution**: Mark XCTestCase subclass as `nonisolated`:\n\n```swift\n\u002F\u002F ✅ Works with MainActor default isolation\nnonisolated final class PlaygroundTests: XCTestCase {\n    @MainActor\n    override func setUp() async throws {\n        try await super.setUp()\n    }\n\n    @Test @MainActor\n    func testSomething() async {\n        \u002F\u002F Individual tests can be @MainActor\n    }\n}\n```\n\n**Why**: XCTestCase is Objective-C, not annotated for Swift concurrency. Its initializers are `nonisolated`, causing conflicts with MainActor-isolated subclasses.\n\n**Better solution**: Migrate to Swift Testing (`@Suite struct`) which handles isolation properly.\n\n---\n\n## Xcode Optimization for Fast Feedback\n\n### Turn Off Parallel XCTest Execution\n\nSwift Testing runs in parallel by default; XCTest parallelization adds overhead:\n\n```\nTest Plan → Options → Parallelization → \"Swift Testing Only\"\n```\n\n### Turn Off Test Debugger\n\nAttaching the debugger costs ~1 second per run:\n\n```\nScheme → Edit Scheme → Test → Info → ☐ Debugger\n```\n\n### Delete UI Test Templates\n\nXcode's default UI tests slow everything down. Remove them:\n1. Delete UI test target (Project Settings → select target → -)\n2. Delete UI test source folder\n\n### Disable dSYM for Debug Builds\n\n```\nBuild Settings → Debug Information Format\n  Debug: DWARF\n  Release: DWARF with dSYM File\n```\n\n### Check Build Scripts\n\nRun Script phases without defined inputs\u002Foutputs cause full rebuilds. Always specify:\n- Input Files \u002F Input File Lists\n- Output Files \u002F Output File Lists\n\n---\n\n## Checklist\n\n### Before Writing Tests\n- [ ] Identify what can move to a Swift Package (pure logic)\n- [ ] Set up framework target if package isn't viable\n- [ ] Configure Host Application: None for unit tests\n\n### Writing Tests\n- [ ] Use `@Test` with clear display names\n- [ ] Use `#expect` for all assertions\n- [ ] Use `#require` to fail fast on preconditions\n- [ ] Use parameterization for similar test cases\n- [ ] Add `.tags()` for organization\n\n### Async Tests\n- [ ] Mark test functions `async` and use `await`\n- [ ] Use `confirmation()` for callback-based code\n- [ ] Consider `withMainSerialExecutor` for flaky tests\n\n### Parallel Safety\n- [ ] Avoid shared mutable state between tests\n- [ ] Use fresh instances in each test\n- [ ] Only use `.serialized` when absolutely necessary\n\n---\n\n## Resources\n\n**WWDC**: 2024-10179, 2024-10195\n\n**Docs**: \u002Ftesting, \u002Ftesting\u002Fmigratingfromxctest, \u002Ftesting\u002Ftesting-asynchronous-code, \u002Ftesting\u002Fparallelization\n\n**GitHub**: pointfreeco\u002Fswift-concurrency-extras, pointfreeco\u002Fswift-clocks\n\n---\n\n**History:** See git log for changes\n\n",{"name":5,"license":15,"metadata":42,"description":7},{"version":43,"last-updated":44},"1.0.0","WWDC 2024 (Swift Testing framework)","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002FCharlesWiltgen\u002FAxiom\u002Faxiom-swift-testing",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill axiom-swift-testing",{"tool":60,"command":61},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill axiom-swift-testing",{"tool":63,"command":64},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill axiom-swift-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FCharlesWiltgen\u002FAxiom\u002Faxiom-swift-testing\u002FSKILL.md",true,[68],{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"REFERENCE.md","REFERENCE","参考文档",1714,"https:\u002F\u002Fgithub.com\u002Fdanielvm-git\u002Fbigpowers\u002Fblob\u002Fmain\u002Fskills\u002Fchange-request\u002FREFERENCE.md",[75,84,93,102,108,114],{"skillNo":76,"name":77,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":37},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[81,82,83],"model","model hierarchy","model hierarchy skill",{"skillNo":85,"name":86,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":37},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[90,91,92],"MCP","zoom","zoom mcp",{"skillNo":94,"name":95,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":37},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[99,100,101,91],"sdk","zoom apps sdk","apps",{"skillNo":103,"name":104,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":37},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[104],{"skillNo":109,"name":110,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":37},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[110],{"skillNo":115,"name":116,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":37},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[116]]