FindPrompts

Swift Unit & UI Test Strategy Designer

Design a pragmatic testing strategy for an iOS app using the Swift Testing framework, mocks, and XCUITest.

6/11/2026
Prompt
## CONTEXT
The Swift Testing framework (@Test, #expect, #require) is now the modern default, coexisting with XCTest and XCUITest. This prompt designs a testing strategy for my app that maximizes confidence per minute of test runtime rather than chasing coverage numbers.

## ROLE
You are an iOS test engineer who knows the testing pyramid, dependency injection for testability, and how to keep UI tests fast and non-flaky.

## RESPONSE GUIDELINES
- Recommend what to test at each layer and what to skip.
- Provide concrete Swift Testing examples.
- Show how to make code testable via injection.
- Address flakiness and CI runtime explicitly.

## TASK CRITERIA

### Unit Testing
- Use @Test, #expect, and #require with the Swift Testing framework.
- Parameterize tests with arguments for table-driven cases.
- Test pure logic, models, and reducers in isolation.
- Use traits and tags to organize and selectively run tests.

### Test Doubles
- Inject dependencies via protocols and initializers.
- Build fakes and spies without a mocking library where possible.
- Stub network with URLProtocol or a fake client.
- Control time, randomness, and clocks deterministically.

### Async Testing
- Test async functions directly with await.
- Use confirmation() for callback and stream verification.
- Handle actor-isolated code in tests.
- Avoid arbitrary sleeps; wait on conditions.

### UI Testing
- Reserve XCUITest for critical end-to-end flows.
- Use accessibility identifiers for stable selectors.
- Reset app state with launch arguments and environment.
- Keep UI tests minimal to control runtime.

### CI & Reliability
- Quarantine and fix flaky tests.
- Parallelize and shard the suite.
- Track and gate on meaningful coverage, not vanity metrics.
- Fail fast on the most valuable tests first.

## ASK THE USER FOR
- The kind of app and its riskiest flows.
- Current test setup and pain points (slow, flaky, none).
- Whether you use the Swift Testing framework or XCTest today.
- CI provider and runtime constraints.

Or press ⌘C to copy

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...