ios-testinglisted
iOS testing expert skill covering Swift Testing framework (@Test, #expect, #require, @Suite, parameterized tests, traits), XCTest (assertions, async testing, performance testing, XCTestExpectation), UI Testing (XCUIApplication, XCUIElement, Page Object pattern, accessibility identifiers), snapshot testing (swift-snapshot-testing), mocking strategies (protocol-based mocks, URLProtocol for network, test doubles), and testing patterns for SwiftUI, SwiftData, Combine, and async/await code. Use this skill whenever the user writes tests, creates test classes, needs mocking strategies, or asks about testing iOS code. Triggers on: test, @Test, #expect, XCTest, XCTestCase, unit test, UI test, integration test, mock, stub, spy, fake, snapshot test, test coverage, TDD, testing, assert, XCTAssert, Swift Testing, @Suite, parameterized test, test plan, test double, URLProtocol mock, ViewInspector, or any iOS testing question.
ebbaunqualified520/ios-agent-skills · ★ 0 · Testing & QA · score 72
Install: claude install-skill ebbaunqualified520/ios-agent-skills
# iOS Testing Skill
## Core Rules
1. **Use Swift Testing (`@Test`, `#expect`) for ALL new unit tests** -- it is the modern framework (Xcode 16+).
2. **Keep XCTest only for UI tests and performance tests** -- Swift Testing does not support these yet.
3. Both frameworks can coexist in the same target -- migrate incrementally, never rewrite working tests.
4. Use **protocol-based dependency injection** for testability.
5. Use **`URLProtocol`** for network mocking (NOT mocking URLSession directly).
6. Use **`isStoredInMemoryOnly: true`** for SwiftData test containers.
7. Name tests descriptively: `@Test("Login succeeds with valid credentials")`.
8. One assertion per test is ideal, but pragmatic grouping is fine.
9. **Test behavior, not implementation details.**
10. Never use `sleep()` in tests -- use expectations, confirmations, or `Clock` injection.
## Framework Choice
| Test Type | Framework | Why |
|-----------|-----------|-----|
| Unit tests (new) | Swift Testing | Modern, less boilerplate, parameterized tests |
| Unit tests (existing) | XCTest | Don't rewrite working tests without reason |
| UI tests | XCTest | Swift Testing doesn't support XCUIApplication |
| Performance tests | XCTest | `measure {}` not available in Swift Testing |
| Snapshot tests | XCTest + swift-snapshot-testing | Point-Free library, XCTest integration |
## Test Organization
```
MyAppTests/ # Unit test target
Models/
UserTests.swift
OrderTests.swift
ViewModels/
Lo