22.1 · The pyramid, and what not to test
A test suite is an investment with running costs. The goal is the most confidence per minute of waiting and per hour of maintenance, which means choosing the cheapest kind of test that can catch each kind of bug.
Mental model. Push each check as low as it can go: logic in fast unit tests, wiring in a few integration tests, and only the critical journeys in slow UI tests.
Shape and scope
The layers of tests, their costs, and what is not worth a test.
- What is the test pyramid for an iOS app, and what does each layer cost and catch?
The pyramid is a rule of thumb about proportion: many fast, narrow tests at the bottom, fewer broad ones above. Unit tests exercise one type or function in… - What should you not test, and how do you decide whether a test is worth having?
A test is worth having if it fails when behaviour users or other code depend on breaks, and stays quiet when you refactor. By that standard a lot of tests are…
More in Testing
- 22.2 · XCTest and Swift Testing
- 22.3 · Async tests, expectations and controlling time
- 22.4 · Fakes, mocks and the inputs that make tests random
- 22.5 · Snapshot tests and UI tests
- 22.6 · Testing SwiftUI, tvOS focus, and watchOS logic
- 22.7 · Flakes, hermetic CI, and a quality system for a large team
- 22.8 · Swift Testing in depth: arguments, traits, errors, confirmations, isolation and scoping
- 22.9 · XCTest lifecycle and expectations, Sendable doubles, and the main actor in tests