swift-unit-testing-skilllisted
Install: claude install-skill fal3/claude-skills-collection
# Swift Unit Testing
Build deterministic tests around observable behavior. Prefer Swift Testing for new Swift unit and integration tests; choose XCTest only where it still provides the required runner or API.
## Compatibility baseline
- Swift Testing requires Swift 6 / Xcode 16 or newer. It supports Apple platforms, Linux, and Windows.
- XCTest remains appropriate for `XCUIApplication`, `XCTMetric`, Objective-C tests, and incremental maintenance of existing XCTest suites.
- Swift Testing and XCTest can coexist in one test target. Do not mix `@Test` methods into an `XCTestCase` subclass.
- State the app's actual deployment targets and CI Xcode version before recommending availability-sensitive traits or APIs.
- Treat APIs first introduced after the installed SDK as future-cycle features and gate them explicitly.
## Select the test layer
| Goal | Default |
| --- | --- |
| Pure Swift unit or integration behavior | Swift Testing |
| Async/throws, parameterized cases, traits, tags | Swift Testing |
| UIKit/SwiftUI end-to-end interaction | XCTest UI testing |
| Runtime, CPU, memory, launch, or signpost metrics | XCTest performance APIs |
| Objective-C test code or legacy suite | XCTest |
Do not replace a unit test with a UI test. Keep network, database, clock, randomness, and notification boundaries injectable so unit tests remain fast and deterministic.
## Workflow
1. Identify the behavior and public boundary under test.
2. List failure cases, cancellation behavior, and st