Testing Swift code that talks to the file system or network can be tricky. This pattern solves that problem by using small protocols to represent each external service. You can then swap real services with mock versions during tests.
You define a protocol for each concern like reading files or saving data. Then you create a production version that uses the real system and a mock version that runs in memory. Your code asks for these services through dependency injection with default values.
This approach makes tests fast and reliable. You can test error paths without triggering real failures. Your code works in apps, tests, and even SwiftUI previews with no changes.
Global
mkdir -p ~/.claude/skills/swift-protocol-di-testingProject
mkdir -p .claude/skills/swift-protocol-di-testingSource Repository
Grill Memattpocock/skills
Stress-test your plan with relentless questions until we both understand
Tddmattpocock/skills
Write one test at a time then code to make it pass
Test Driven Developmentobra/superpowers
Write a failing test first then code just enough to pass
Webapp Testinganthropics/skills
Test your local web apps quickly with Playwright automation and screenshots
Qamattpocock/skills
Turn bug reports into GitHub issues through natural conversation without technical fuss
Migrate To Shoehornmattpocock/skills
Replace unsafe as assertions with type-safe partial test data easily
Playwright Best Practicescurrents-dev/playwright-best-practices-skill
Master Playwright testing with best practices for reliable and fast tests
Google Agents Cli Evalgoogle/agents-cli
Run evaluations on your AI agent, find failures, and improve its quality step by step