Implements protocol-based dependency injection patterns to create highly testable Swift code with mockable external dependencies.
This skill provides a structured approach to Swift architecture by abstracting external concerns—such as file systems, network layers, and iCloud—behind small, focused protocols. It enables developers to write deterministic unit tests using the Swift Testing framework, simulate complex error paths without real-world failures, and ensure thread safety via Sendable conformance. By utilizing default parameter injection, this pattern maintains clean production code while allowing seamless mocking for tests and SwiftUI Previews.
주요 기능
01Configurable error simulation for testing failure paths
02Default parameter injection for production-test parity
031 GitHub stars
04Protocol-based abstraction for external I/O and APIs
05Swift Concurrency support with Sendable conformance
06Mock implementation patterns for deterministic testing
사용 사례
01Providing mock data for SwiftUI Previews without triggering side effects
02Simulating network failures or API responses in isolated unit tests
03Mocking file system access for sandboxed iOS and macOS apps