Swift Protocol Di Testing
Protocol-based dependency injection patterns that let Swift code be tested without touching real file systems or networks.
- CCM score
- 77 of 100
- skills.sh installs
- 12K
- GitHub stars
- 312.6K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers small focused protocols for file system, file access, and bookmark storage, each with a production default and a configurable mock
- Includes Sendable-conforming mock implementations with injectable error properties for exercising failure paths deterministically
- Enforces one concern per protocol and mocking only external boundaries, not internal types with no external dependencies
- Designed for Swift code using actors and Swift Testing that must run in app, test, and SwiftUI preview contexts
Install
$ npx -y skills add affaan-m/ecc --skill swift-protocol-di-testing -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Swift Protocol-Based Dependency Injection for Testing
Patterns for making Swift code testable by abstracting external dependencies (file system, network, iCloud) behind small, focused protocols. Enables deterministic tests without I/O.
When to Activate
- Writing Swift code that accesses file system, network, or external APIs
- Need to test error handling paths without triggering real failures
- Building modules that work across environments (app, test, SwiftUI preview)
- Designing testable architecture with Swift concurrency (actors, Sendable)
Core Pattern
1. Define Small, Focused Protocols
Each protocol handles exactly one external concern.
// File system access
public protocol FileSystemProviding: Sendable {
func containerURL(for purpose: Purpose) -> URL?
}
// File read/write operations
public protocol FileAccessorProviding: Sendable {
func read(from url: URL) throws -> Data
func write(_ data: Data, to url: URL) throws
func fileExists(at url: URL) -> Bool
}
Details
- Repository
- github.com/affaan-m/ecc
- Categories
- Testing & QA, Mobile Apps
- First seen
- Jul 14, 2026
Questions
What does the swift-protocol-di-testing skill do?
It makes Swift code testable by putting external dependencies like the file system, network, and external APIs behind small, focused protocols. Its tests are written with Swift Testing and run deterministically without real I/O.
How do I install the swift-protocol-di-testing skill?
Run npx -y skills add affaan-m/ecc --skill swift-protocol-di-testing -y in your project. The skill then lets your agent write Swift code with injectable protocols and mock implementations for tests.
Which category does swift-protocol-di-testing belong to and how does it rank?
It is in the Testing & QA category, where it ranks in the top 50. It sits alongside skills such as tdd, webapp-testing and test-driven-development in that category.
When should I use swift-protocol-di-testing?
Use it when Swift code touches the file system, network, or external APIs and you need to test error paths without triggering real failures. It also helps modules that must run in app, test, and SwiftUI preview contexts.
More from affaan-m/ecc
All 257- Blueprint12K
- Git Workflow11.9K
- Foundation Models On Device11.9K
- Exa Search11.9K
- Swift Concurrency 6 211.9K
- Nestjs Patterns11.9K
- Data Scraper Agent11.9K
- Hexagonal Architecture11.9K
- Mcp Server Patterns11.9K
- Plankton Code Quality11.9K
- Fal Ai Media11.8K
- Visa Doc Translate11.8K
- Inventory Demand Planning11.8K
- Customs Trade Compliance11.8K
- Brand Voice11.8K
- Seo11.7K
- Kotlin Ktor Patterns11.7K
- Enterprise Agent Ops11.7K
- Quality Nonconformance11.7K
- Ralphinho Rfc Pipeline11.7K
- Crosspost11.7K
- Agent Eval11.7K
- Production Scheduling11.6K
- Videodb11.6K
Similar to Swift Protocol Di Testing
More Testing & QAswift-testingbocato/swift-testing-agent-skill293 installsSwift Testing framework guidance covering test doubles, fixtures, async, parameterized, and snapshot testing patterns.
ios-testingpproenca/dot-skills292 installsComprehensive iOS testing guide for Swift 6.2 clinic MVVM-C apps, covering 44 rules across eight categories.
mocking-stubbingaj-geddes/useful-ai-prompts434 installsStructured guide for isolating unit tests with mocks, stubs, spies, and test doubles across Jest, unittest.mock, and Mockito.
testing-patternsvudovn/ag-kit215 installsReference guide of testing principles covering the test pyramid, AAA structure, and mocking strategies for reliable suites.
unit-test-service-layergiuseppe-trisciuoglio/developer-kit4K installsMockito-based unit test patterns for @Service classes that isolate business logic from databases and external APIs.
fsharp-testingaffaan-m/ecc8.5K installsF# testing patterns covering xUnit, FsUnit, Unquote, and FsCheck property-based tests for .NET projects.