ios-testing-and-benchmark

Implements XCTest unit tests, XCUITest flows, and XCTMetric performance benchmarks for iOS apps.

Updated Jun 13, 2026
One-click install
npx skills add https://github.com/22Teikk/22Teikk-Agent-Skills-Hub --skill ios-testing-and-benchmark-22teikk
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ios-testing-and-benchmark
Source: https://github.com/22Teikk/22Teikk-Agent-Skills-Hub/tree/main/packs/ios/skills/ios-testing-and-benchmark
Command: npx skills add https://github.com/22Teikk/22Teikk-Agent-Skills-Hub --skill ios-testing-and-benchmark-22teikk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? iOS codebases often ship with tautological mock-verification tests, flaky network-dependent suites, and no performance regression coverage, letting data-layer bugs and startup slowdowns reach production undetected. ## Core Features & Use Cases - XCTest Unit Testing: Write async throws tests for view models and repositories using protocol-based test doubles, with Swift Testing (#expect) support on iOS 17+. - Hermetic Test Doubles: Stub network calls via URLProtocol and run data-layer tests against a real in-memory SwiftData ModelContainer instead of mocked repositories. - UI and Performance Testing: Build XCUITest multi-screen flows keyed on accessibilityIdentifier, and benchmark startup, scrolling, and CPU with XCTMetric plus OS signposts for Instruments correlation. - Use Case: When adding a transaction repository, write an in-memory SwiftData test asserting exact Int64 minor-unit sums, catching money-as-Double drift before it ships. ## Quick Start Write XCTest unit tests with async throws for my TaskListModel, stub the API with URLProtocol, and add an XCTMetric startup benchmark.

Frequently Asked Questions about ios-testing-and-benchmark

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write async unit tests in XCTest for Swift view models?▼

Mark test functions as `func testFoo() async throws` and annotate them `@MainActor` when they touch MainActor-isolated view models. Use `#expect` with Swift Testing on iOS 17+, or `XCTAssert*` for established suites, with one assertion focus per test.

How to mock URLSession network requests in Swift tests?▼

Stub URLSession by subclassing URLProtocol and registering it via `URLSessionConfiguration.ephemeral.protocolClasses`. A static handler closure returns canned HTTPURLResponse and Data, giving deterministic, hermetic tests without hitting staging servers.

XCTest vs Swift Testing: which should I use for iOS?▼

Swift Testing with `@Test` and `#expect` is preferred for new tests on iOS 17+, offering clearer failure output and async support. Legacy `XCTAssert*` remains fine for established XCTest suites that predate Swift Testing.

Why should SwiftData tests use an in-memory ModelContainer instead of mocks?▼

A mocked repository that returns the value you passed in proves nothing about SQLite behavior. An in-memory ModelContainer runs the real store, catching wrong column types, bad predicates, and broken migrations while staying fast.

How do I measure iOS app startup time and scroll performance in tests?▼

Use XCTMetric subclasses in a `measure` block: XCTClockMetric for startup wall-clock time and XCTOSSignpostMetric.scrollDecelerationMetric for scroll performance. Add OS signposts in code so Instruments traces align with the measured intervals.

When should I use XCUITest instead of unit tests on iOS?▼

Reserve XCUITest for true cross-screen journeys like login to home to detail, since it is slow and flaky on animations. Cover view models and repositories in unit tests, and always query elements by accessibilityIdentifier, never coordinates.