swift-testing-playbook

swift-testing-playbook is a cursor rule for coding agents from roy2392/vibe-agents-rules. It costs 0 tokens per session (5,978 once invoked), scanned A, a copy of swift-testing-playbook, MIT.

A guide to Swift Testing, Apple's newer framework for writing tests, and to moving tests from XCTest to it.

In plain words
What is it for?
Use it when setting up Swift Testing, converting XCTest files, configuring test execution, or applying the guide's recommended testing patterns.
Why use it?
It explains how to migrate gradually while keeping existing XCTest tests working alongside the new tests.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/roy2392/vibe-agents-rules/swift-testing-playbook
Clone the repo
git clone --depth 1 https://github.com/roy2392/vibe-agents-rules

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for swift-testing-playbook

README.md
[![agentmods](https://agentmods.dev/badge/rules/roy2392/vibe-agents-rules/swift-testing-playbook.svg)](https://agentmods.dev/rules/roy2392/vibe-agents-rules/swift-testing-playbook)
Your own site
<a href="https://agentmods.dev/rules/roy2392/vibe-agents-rules/swift-testing-playbook"><img src="https://agentmods.dev/badge/rules/roy2392/vibe-agents-rules/swift-testing-playbook.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 5,978 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.05978
Opus 5 $0.00000 $0.02989
Sonnet 5 $0.00000 $0.01196
Haiku 4.5 $0.00000 $0.00598

Measured 5d ago against content hash 7199aeb7d6ce, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

swift-testing-playbook scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to swift-testing-playbook — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

docs/swift-testing-playbook.mdc · 454 lines

How it starts

The opening of the file, as written. The whole thing — 454 lines — stays where its author put it; the contents beside it link to each section on GitHub.

The Ultimate Swift Testing Playbook (2024 WWDC Edition, expanded with Apple docs from June 2025)

https://developer.apple.com/xcode/swift-testing/

A hands-on, comprehensive guide for migrating from XCTest to Swift Testing and mastering the new framework. This playbook integrates the latest patterns and best practices from WWDC 2024 and official Apple documentation to make your tests more powerful, expressive, and maintainable.


1. Migration & Tooling Baseline

Ensure your environment is set up for a smooth, gradual migration.

What Why
Xcode 16 & Swift 6 Swift Testing is bundled with the latest toolchain. It leverages modern Swift features like macros, structured concurrency, and powerful type-system checks.
Keep XCTest Targets Incremental Migration is Key. You can have XCTest and Swift Testing tests in the same target, allowing you to migrate file-by-file without breaking CI. Both frameworks can coexist.
Enable Parallel Execution In your Test Plan, ensure "Use parallel execution" is enabled. Swift Testing runs tests in parallel by default, which dramatically speeds up test runs and helps surface hidden state dependencies that serial execution might miss.

Migration Action Items

  • Ensure all developer machines and CI runners are on macOS 15+ and Xcode 16+.
  • For projects supporting Linux/Windows, add the swift-testing SPM package to your Package.swift. It's bundled in Xcode and not needed for Apple platforms.
  • For existing test targets, you must explicitly enable the framework. In the target's Build Settings, find Enable Testing Frameworks and set its value to Yes. Without this, import Testing will fail.
  • In your primary test plan, confirm that “Use parallel execution” is enabled. This is the default and recommended setting.

2. Expressive Assertions: #expect & #require

Replace the entire XCTAssert family with two powerful, expressive macros. They accept regular Swift expressions, eliminating the need for dozens of specialized XCTAssert functions.

Read the full file on GitHub · 454 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 454 lines · 0 tokens per session scan A 7199aeb7d6ce

Subscribe to this mod's changes

swift-testing-playbook is a cursor rule published in the GitHub repository roy2392/vibe-agents-rules (11 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 5,978 tokens. A static security scan graded it A with 0 findings. It is 100% identical to swift-testing-playbook, differing in 0 lines, and is treated as a copy.