swift-testing-code-review
Reviews Swift Testing code for proper use of #expect/#require, parameterized tests, async testing, and suite organization. Use when reviewing .swift files with import Testing, @Test, #expect, @Suite,
Files5
View on GitHubSKILL.mdskills/swift-testing-code-review/SKILL.md
GitHubSwift Testing Code Review
Hard gates
Complete in order before recording Swift Testing review findings. Stack with review-verification-protocol at review-verification-protocol for universal review rules.
- Scope: You have an explicit list of
.swiftpaths under review (or a user-named single file). Pass: Paths captured in working notes or one line:No Swift files in scope— then stop with no findings. - Swift Testing surface: For each path you treat as Swift Testing code, confirm
import Testingor@Test/#expect/#require/@Suiteappears in that file (open or search). Pass: At least one match per critiqued file, or you exclude that file from Swift Testing review with a one-line reason (e.g. XCTest-only). - Evidence + protocol: Load
review-verification-protocolat review-verification-protocol before asserting any issue. Pass: Each finding meets that skill’s anchor rules; any violated Review Checklist item cites[FILE:LINE]evidence. If you report zero issues, stateProtocol applied; no Swift Testing issues(or equivalent) in the review summary.
Quick Reference
| Issue Type | Reference |
|---|---|
#expect vs #require, expression capture, error testing |
references/expect-macro.md |
@Test with arguments, traits, zip() pitfalls |
references/parameterized.md |
confirmation, async sequences, continuations, exit tests |
references/async-testing.md |
@Suite, tags, parallel execution, .serialized, TestScoping |
references/organization.md |
Review Checklist
- Expressions embedded directly in
#expect(not pre-computed booleans) -
#requireused only for preconditions,#expectfor assertions - Error tests check specific types (
try #require(throws: ErrorType.self)+#expect, not generic(any Error).selfor deprecatedthrows:closure) - Parameterized tests with pairs use
zip()(not accidental Cartesian product) - No logic mirroring implementation in parameterized expected values
- Async sequences tested with
confirmation(expectedCount:) - Completion handlers use
withCheckedContinuation(neverconfirmationor XCTestexpectation/fulfillmentinside@Test) - Process crashes (
precondition/fatalError) tested with#expect(processExitsWith:)(Swift 6.2+), not skipped or untested -
.serializedapplied only where necessary (shared resources); sibling serialized suites nested under a parent - Custom setup/teardown or task-local bindings use
init/deinitorTestScopingtraits (Swift 6.1+), with no shared mutable static state - Disabled tests have explanations and
.bug(...)links
When to Load References
- Reviewing
#expector#requireusage -> references/expect-macro.md - Reviewing
@Testwith arguments or traits -> references/parameterized.md - Reviewing
confirmation, async testing, or exit tests -> references/async-testing.md - Reviewing
@Suite,TestScoping, or test organization -> references/organization.md
Review Questions
- Could pre-computed booleans in
#expectlose diagnostic context? - Is
#requirestopping tests prematurely instead of revealing all failures? - Are multi-argument parameterized tests creating accidental Cartesian products?
- Could
zip()silently drop test cases due to unequal array lengths? - Are completion handlers or unstructured
Tasks incorrectly tested withconfirmationor XCTestfulfillment?