writing-swift-unit-tests
CommunityWrite deterministic, production-quality Swift unit tests
Authorfeosuna1
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Reduces flakiness, implementation coupling, and inconsistent practices when adding or modifying Swift unit tests by providing clear conventions and a checklist to produce deterministic, maintainable tests.
Core Features & Use Cases
- Framework guidance: Prefer Swift Testing for new tests and use XCTest only when extending existing XCTest-based files, with a documented rationale when deviating.
- Conventions for clarity: Require literal test names, avoid redundant suite annotations, and use assertion helpers (#expect / #require) rather than XCTAssert in Swift Testing.
- Quality and determinism: Emphasize observable behavior testing, minimal mocking, single behavioral intent per test, async and cancellation verification, and avoidance of time-based sleeps.
- Use case: When adding tests for a networking or business logic component, follow these rules to ensure tests are deterministic, focused on behavior, and easy to maintain.
Quick Start
Create or update the unit test file using Swift Testing by default, name tests with descriptive literal names, use #expect and #require for assertions, and verify deterministic behavior including edge and failure cases.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: writing-swift-unit-tests Download link: https://github.com/feosuna1/dotfiles/archive/main.zip#writing-swift-unit-tests Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.