What problem does it solve?
This Skill addresses the challenge of writing testable Swift code by providing a robust pattern for dependency injection, enabling deterministic testing of components that interact with external systems like the file system or network.
Core Features & Use Cases
- Protocol-Based Abstraction: Define small, focused protocols for external dependencies (file system, network, etc.).
- Mock Implementations: Create mock versions of these protocols for use in testing environments.
- Dependency Injection: Inject default (production) or mock implementations into your actors and classes.
- Testable Swift Concurrency: Ensures compatibility with Swift's actor model and
Sendable requirements.
- Use Case: Test complex data synchronization logic without needing a live network connection or actual file system access by injecting mock implementations of
FileSystemProviding and FileAccessorProviding.
Quick Start
Use the swift-protocol-di-testing skill to generate a mock file accessor for testing purposes.