What problem does it solve?
This Skill helps developers write deterministic, testable Swift code by abstracting external dependencies such as file system, network, and bookmark storage behind small, focused protocols so tests can run without performing real I/O and can simulate failure modes.
Core Features & Use Cases
- Focused Protocols: Define small protocols for single responsibilities (file system, file access, bookmark storage) to minimize surface area to mock.
- Production Defaults + Mocks: Provide default production implementations and configurable mock providers that simulate reads, writes, and error conditions.
- Actor & Concurrency Friendly: Enforce Sendable conformance and patterns for injecting dependencies into actors and async components.
- Use Cases: Unit testing a SyncManager that reads/writes JSON from a container, simulating missing containers or read/write errors, and enabling reliable SwiftUI previews without real services.
Quick Start
Use the swift-protocol-di-testing skill to extract external I/O into focused protocols, add default and mock implementations, and inject mocks into your unit tests to simulate success and failure scenarios.