dimitriremoiville/cc-mobile/ios-testing
Claude Code and agent skill by dimitriremoiville/cc-mobile
- community
Checking that the SKILL.md file is still in the repository.
Project-specific testing conventions on top of Swift Testing + XCTest UI automation — `Outcome` in stub returns, the `@MainActor` view-model suite shape, the full-state-sequence assertion rule, hand-rolled stubs vs fakes, and the `URLProtocol` network seam. Load when writing, updating, or debugging tests of any kind.
Install
npx vskill@latest install dimitriremoiville/cc-mobile/ios-testingSKILL.md
The same SKILL.md was published earlier as dimitriremoiville/cc-mobile/ios-testing.
Testing (project delta)
For testing fundamentals — @Test / @Suite / #expect / #require semantics, parameterised tests, traits, XCUIApplication querying — read Apple's Swift Testing documentation and the XCTest UI testing guide. This file documents only this project's conventions. The scaffolded seed suites live in .claude/skills/ios-app-skeleton/references/tests.md.
When this applies
Swift Testing for unit and integration, XCTest for UI automation, hand-rolled test doubles. On an existing app:
- XCTest-only (no
import Testing, or an Xcode < 16 floor) → keep it. Write new tests in XCTest to match; the assertions differ, every rule below still applies. - Quick / Nimble (
describe,it,expect(...).to(...)) → keep the BDD style for that target rather than mixing two vocabularies in one file. - A mocking library (Cuckoo, Mockingbird, generated mocks) → keep it. Don't hand-roll new doubles alongside generated ones.
- Snapshot tests (
swift-snapshot-testing) → complementary, not a substitute for the view-model tests below. Note the recorded-reference maintenance cost when it's relevant.
Two frameworks, split by kind
| Kind | Framework | Where | |
|---|---|---|---|
| Domain, use cases, mappers, repositories | Swift Testing | Tests/AppCoreTests/ | |
| View models | Swift Testing, @MainActor suite | Tests/AppFeaturesTests/ | |
| UI / E2E | XCTest + XCUIApplication | UITests/ |
Swift Testing doesn't cover UI automation, so UI tests stay XCTest. That's the only reason to write a new XCTestCase.
Outcome in test doubles
Repository and use-case doubles return Outcome.success(...) / .failure(DomainError.x) — not Result, not a thrown error, unless the real signature throws. Matching the production signature is what makes the test exercise the real mapping path.
View-model suites
View models are @MainActor, so the suite is too:
Two rules that catch real bugs:
- Assert the whole state sequence the test cares about, including the initial
.loading, not just the final value. A view model that jumps straight to.loadedand never shows a spinner passes a final-value-only assertion. - Await the method under test. There is no scheduler to advance here, but there is also no polling:
while model.state == .loading { }in a test is always wrong.
Stubs vs fakes
- Stub — returns a scripted answer, ignores input. Default choice for a one- or two-method protocol.
- Fake — working in-memory behaviour. Worth it once a protocol has more than two methods, or when a test needs write-then-read.
Both are hand-rolled final classes in the test target. Mark one @unchecked Sendable only when it genuinely crosses an actor boundary and you've made it thread-safe — a lock, or immutability.
The network seam
Test URLSession code by injecting a session configured with a custom URLProtocol:
The static handler is shared mutable state, so suites using it need @Suite(.serialized). Reset it in the test that sets it, not in a shared teardown, or a parallel run will read someone else's handler.
UI tests
Stub the data behind a launch argument so the run never touches the network:
Keep UI tests to navigation and visible results — a UI test asserting business logic is a slow, flaky unit test.
Rules of thumb
- One concept per test. Five loosely related assertions in one function is a smell.
- No real IO in unit tests. No live
URLSession, no on-disk SwiftData, no real Keychain. - Deterministic time. Inject
() -> Dateor aClock; never callDate()inside the type under test. - Name tests as sentences —
loadMovesFromLoadingToLoaded(), or a@Test("...")description.
Don'ts
- No `XCTestExpectation` / `wait(for:)` in new async tests —
awaitthe thing. - No `Thread.sleep`. If you're waiting on async work, await it; if you're waiting on a UI element,
waitForExistence(timeout:). - No test that depends on another test's side effects. Swift Testing runs suites in parallel by default.
- No `#expect(true)`. A test that can't fail is a liability with a green checkmark.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingios/.claude/skills/ios-testing/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dimitriremoiville/cc-mobile/ios-testing)