Swift Protocol-Based DI for Testing
Make Swift testable with Muse: small focused protocols for file system, network and APIs, default production implementations, in-memory mocks, and Swift Testing examples.
- What
- Make Swift testable with Muse: small focused protocols for file system, network and APIs, default production implementations, in-memory mocks, and Swift Testing examples.
- Cost
- Free
- Needs
- Use "Swift Protocol-Based DI for Testing" with your Muse.
- Install
- Copy the installer prompt below into your Muse — your agent does the rest.
Curated by Skill Harbor: a pattern guide that makes Swift code testable by abstracting every external dependency behind small, focused protocols. Each protocol handles exactly one concern (file system access, file read/write, bookmark storage and the like), with a production implementation using the real APIs and a mock implementation using in-memory dictionaries plus configurable error properties for testing failure paths. Dependencies are injected with default parameters, so production code reads cleanly while tests swap in mocks. The guide includes full Swift Testing examples: missing-container errors, successful reads, and corrupt-file error handling, plus best practices (single responsibility per protocol, Sendable conformance for actor boundaries, mock external boundaries only, default parameters for production) and anti-patterns (god protocols, mocking internal types, #if DEBUG conditionals instead of real injection, forgetting Sendable, over-engineering types with no external dependencies). By @affaan-m, listed here with credit to its creator. From the affaan-m/ECC repository (MIT). Honest caveats: it assumes comfort with Swift concurrency (actors, Sendable); if a type has no external dependencies it needs no protocol at all. Skill Harbor never reviews the code, review it yourself before use.
Version:
Install
Copy the install package below, then paste it into MuseThe install prompt below already includes the vetting steps: your agent follows the community checklist before installing anything with executable code. Want more?
Use "Swift Protocol-Based DI for Testing" with your Muse. Prerequisites: none to install. Pure guidance; a Swift project helps (Swift 6 concurrency assumed). 1. Open the skill: https://github.com/affaan-m/ECC/blob/main/skills/swift-protocol-di-testing/SKILL.md and copy the full SKILL.md text. 2. Paste it into a chat with Muse and add: "Refactor this Swift type for testability with protocol-based DI: [paste code]." 3. Ask follow-ups like "write the mock and a Swift Testing test for the failure path" or "check Sendable conformance across these protocols." Tip: start with the types that touch the file system or network; pure logic types need no protocols. Safety: a skill is plain-text instructions; it runs nothing by itself. Review generated commands before running them.
Saved to your recent installs. Find it anytime on /connect.
Questions
How do I install a build?
Every product page includes a copy-paste install prompt. Paste it into your Muse and it sets the build up for you — no manual configuration.
Where does my money go?
Straight to the seller. Skill Harbor never processes payments: checkout happens on the seller’s own page, usually Stripe.
What does the ✓ next to a creator’s name mean?
It means we confirmed the identity of the person behind the listing. It says nothing about the code itself — always check a build before installing it.