Test and Verify
2 min read
Test and Verify
Testing an iOS app is not optional — App Store review and real users will find every edge case you skip here. This doc covers the testing layers, in order of how useful each one is.
Add the test targets
If you skipped test targets when creating the project (as recommended in Doc 5), add them now:
- In Xcode: File → New → Target
- Choose Unit Testing Bundle — name it {AppName}Tests
- Add a second target: UI Testing Bundle — name it {AppName}UITests
Unit tests with Claude Code
bash
Write unit tests for [AppName]Tests covering:
1. All @Observable view models — test that state changes correctly2. Core data operations — test create, read, update, delete3. Any business logic functions in Core/4. Edge cases from the PRD: empty states, error states, maximum values
Use Swift Testing framework (@Test, @Suite) not XCTest where possible.Mock dependencies using protocol-based injection — no network calls in unit tests.Aim for >80% coverage of the Core/ and ViewModels/ folders.UI tests for critical paths
bash
Write UI tests in [AppName]UITests for these critical user flows:
1. [First critical flow from PRD — e.g., onboarding to main screen]2. [Second critical flow — e.g., creating the core entity]3. [Third critical flow — e.g., completing the main action]
Use XCUITest. Each test must:- Start from a clean state (delete app data in setUp)- Complete the full flow end-to-end- Assert the expected final stateSimulator testing matrix
Test on these Simulators before submitting to TestFlight:
- iPhone SE (3rd gen) — smallest current iPhone, 4.7" screen. Tests your layout at minimum size.
- iPhone 16 — base current model
- iPhone 16 Pro Max — largest screen, Dynamic Island
- If your app supports iPad: iPad 10th gen + iPad Pro 12.9"
bash
# Run tests on all Simulators from terminal:xcodebuild test -scheme [AppName] \ -destination "platform=iOS Simulator,name=iPhone SE (3rd generation)" \ -destination "platform=iOS Simulator,name=iPhone 16 Pro Max"Physical device testing
Some features only work on real hardware. Before TestFlight, test on device:
- Push notifications — Simulator can't receive real APNs pushes
- Camera — Simulator has a fake camera feed
- Haptics — Simulator plays sounds instead
- Performance — Simulator uses your Mac's CPU, not the phone's A-series chip
- Face ID / Touch ID — Simulator can simulate but feels different
Connect your iPhone via USB, select it in Xcode's device picker, press Cmd+R.
Accessibility audit
bash
# In Simulator: Xcode menu → Open Developer Tool → Accessibility Inspector# Or run from terminal:xcrun simctl spawn booted xctest /path/to/your/appAlso test with VoiceOver on a physical device (Settings → Accessibility → VoiceOver). Every interactive element needs an accessibility label.
Checkpoint before Deploy
- Unit tests pass (xcodebuild test returns 0)
- UI tests pass for all three critical flows
- App runs on iPhone SE without layout issues
- App runs on iPhone 16 Pro Max without excessive whitespace
- Tested on physical device (if possible)
- VoiceOver can navigate the main flows
- Dark mode looks correct on all screens
Sign up to read the full guide
Free access to all 12 workflow guides. No password needed.