swift-testing-code-review

Reviews Swift Testing code for correct #expect, #require, parameterized, and async test patterns.

2|Updated May 25, 2026
One-click install
npx skills add https://github.com/edheltzel/Do-Skills --skill swift-testing-code-review-edheltzel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: swift-testing-code-review
Source: https://github.com/edheltzel/Do-Skills/tree/main/skills/engineering/swift/do-review-ios/references/swift-testing-code-review
Command: npx skills add https://github.com/edheltzel/Do-Skills --skill swift-testing-code-review-edheltzel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Swift Testing introduces new macros and concurrency patterns that are easy to misuse, leading to flaky tests, lost diagnostic context, and silently dropped test cases. This Skill provides a structured review checklist and reference guides to catch these anti-patterns during code review. ## Core Features & Use Cases - Macro Review: Verifies #expect embeds expressions directly, #require is reserved for preconditions, and error tests check specific types rather than generic (any Error).self. - Parameterized Test Audit: Detects accidental Cartesian products, silent zip() drops from unequal arrays, and test logic that mirrors the implementation. - Async & Organization Checks: Catches confirmation misuse with completion handlers, unsafe counters, over-serialization, and assumptions of state persistence between tests. - Use Case: When reviewing a pull request containing files with import Testing, @Test, or @Suite, apply the checklist to flag issues like a completion handler tested with confirmation instead of withCheckedContinuation. ## Quick Start Review the Swift test files in this pull request for Swift Testing anti-patterns using the checklist.

Frequently Asked Questions about swift-testing-code-review

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review Swift Testing code for common mistakes?▼

Check that #expect embeds expressions directly rather than pre-computed booleans, #require is used only for preconditions, and parameterized tests use zip() for paired arguments. Also verify async tests use confirmation for streams and withCheckedContinuation for completion handlers.

What is the difference between #expect and #require in Swift Testing?▼

#expect is a soft assertion that records a failure and continues execution, while #require is a hard precondition that stops the test immediately on failure. Use #require only when subsequent code cannot proceed without the value, such as unwrapping an optional.

Why do parameterized Swift tests create too many test cases?▼

Passing multiple arrays to @Test(arguments:) creates a Cartesian product of all combinations. Wrap the arrays in zip() to pair elements one-to-one, but ensure equal lengths since zip silently drops extra elements.

Can I use confirmation to test completion handlers in Swift Testing?▼

No, confirmation uses eager evaluation and the closure exits before the callback fires. Use withCheckedContinuation to convert the callback into awaitable async code, or use XCTest's fulfillment(of:timeout:) for callback-style waiting.

When should I use .serialized in Swift Testing suites?▼

Apply .serialized only when tests share limited resources like databases or external services, since Swift Testing runs tests in parallel by default. Sibling serialized suites that must be mutually exclusive should be nested under a shared parent suite.