本文へ移動
cccskills
無料GitHub で公開日本語紹介

swift-testing-pro

Swift Testingを使う単体・結合テストの作成とレビューを支援します。非同期処理や検証方法を点検し、XCTestからの移行にも対応します。

原文原文の説明を見る

Writes, reviews, and improves Swift Testing code using modern APIs and best practices. Use when reading, writing, or reviewing projects that use Swift Testing.

インストール方法を見る

こんなときに便利

  • 単体・結合テストを作成したいとき
  • 非同期処理のテストを点検したいとき
  • XCTestから移行したいとき
  • 検証方法やテスト構成の改善

日本語での紹介

できること

Swift Testingを使った単体・結合テストの作成、レビュー、改善を支援します。テストの構成、結果を確かめるアサーション、依存関係の渡し方に加え、非同期処理、時間制限、通信のモックも確認します。XCTestからの移行では、検証用APIの置き換えなどを扱います。レビュー結果はファイル別に行番号、問題となるルール、修正前後のコードを示し、優先度も整理します。

こんなときに便利

既存テストの品質を確認したい開発者や、Swift Testingへ移行したいチームに向いています。プロジェクトの慣習を踏まえ、実際に問題のある箇所に絞って見直す方針です。

使い方の例

  • 「このテストをレビューし、修正例をファイル別に示して」
  • 「非同期の通信処理にSwift Testingのテストを追加して」
  • 「既存のXCTestをSwift Testingへ移行して」

注意点

対象はSwift 6.2以降で、使用中のツールチェーンに合わせて判断します。Swift TestingはUIテストに対応していないため、UIテストにはXCTestを使います。ライセンスはMITです。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(9)

  • SKILL.md4.2 KB
  • agents/openai.yaml360 B
  • assets/swift-testing-pro-icon.png3.0 KB
  • assets/swift-testing-pro-icon.svg1.5 KB
  • references/async-tests.md8.4 KB
  • references/core-rules.md3.9 KB
  • references/migrating-from-xctest.md2.0 KB
  • references/new-features.md10.0 KB
  • references/writing-better-tests.md10.8 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Write and review Swift Testing code for correctness, modern API usage, and adherence to project conventions. Report only genuine problems - do not nitpick or invent issues.

Review process:

  1. Ensure tests follow core Swift Testing conventions using references/core-rules.md.
  2. Validate test structure, assertions, dependency injection, and other best practices using references/writing-better-tests.md.
  3. Check async tests, confirmations, time limits, actor isolation, and networking mocks using references/async-tests.md.
  4. Ensure new features like raw identifiers, test scopes, exit tests, and attachments are used correctly using references/new-features.md.
  5. If migrating from XCTest, follow the conversion guidance in references/migrating-from-xctest.md.

If doing partial work, load only the relevant reference files.

Core Instructions

  • Target Swift 6.2 or later, using modern Swift concurrency.
  • As a Swift Testing developer, the user wants all new unit and integration tests to be written using Swift Testing, and they may ask for help migrating existing XCTest code to Swift Testing.
  • Swift Testing does not support UI tests – XCTest must be used there.
  • Use a consistent project structure, with folder layout determined by app features.

Swift Testing evolves with each Swift release, so expect three to four releases each year, each introducing new features. This means existing training data you have will naturally be outdated or missing key features.

This skill specifically draws upon the very latest Swift and Swift Testing code, which means it will suggest things you are not aware of. Treat the user’s installed toolchain as authoritative, but there's a fairly high chance Apple's documentation about the APIs will be stale, so treat them carefully.

Output Format

If the user asks for a review, organize findings by file. For each issue:

  1. State the file and relevant line(s).
  2. Name the rule being violated.
  3. Show a brief before/after code fix.

Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.

If the user asks you to write or improve tests, follow the same rules above but make the changes directly instead of returning a findings report.

Example output:

UserTests.swift

Line 5: Use struct, not class, for test suites.

// Before
class UserTests: XCTestCase {

// After
struct UserTests {

Line 12: Use #expect instead of XCTAssertEqual.

// Before
XCTAssertEqual(user.name, "Taylor")

// After
#expect(user.name == "Taylor")

Line 30: Use #require for preconditions, not #expect.

// Before
#expect(users.isEmpty == false)
let first = users.first!

// After
let first = try #require(users.first)

Summary

  1. Fundamentals (high): Test suite on line 5 should be a struct, not a class inheriting from XCTestCase.
  2. Migration (medium): XCTAssertEqual on line 12 should be migrated to #expect.
  3. Assertions (medium): Force-unwrap on line 30 should use #require to unwrap safely and stop the test early on failure.

End of example.

References

  • references/core-rules.md - core Swift Testing rules: structs over classes, init/deinit over setUp/tearDown, parallel execution, parameterized tests, withKnownIssue, and tags.
  • references/writing-better-tests.md - test hygiene, structuring tests, hidden dependencies, #expect vs #require, Issue.record(), #expect(throws:), and verification methods.
  • references/async-tests.md - serialized tests, confirmation(), time limits, actor isolation, testing pre-concurrency code, and mocking networking.
  • references/new-features.md - raw identifiers, range-based confirmations, test scoping traits, exit tests, attachments, ConditionTrait.evaluate(), and the updated #expect(throws:) return value.
  • references/migrating-from-xctest.md - XCTest-to-Swift Testing conversion steps, assertion mappings, and floating-point tolerance via Swift Numerics.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

app-store-review

無料概要あり

AppleのApp Store審査ガイドラインに沿ってアプリのコードを点検します。課金や個人情報、ログインなどを確認し、申請前に却下につながり得る問題を洗い出します。

  • App Store申請前の点検
  • 課金やサブスクリプションの確認
  • 個人情報とアカウント削除の確認
jacklandrin/OnlySwitch6,0012026年10月21日 更新

onlyswitch-deeplink

無料概要あり

自然な言葉で頼んだ操作をOnlySwitchの内蔵機能に対応付けて実行します。macOSでスリープ防止やダークモードの切り替え、ごみ箱の消去などを呼び出せます。

  • スリープ防止を切り替えたいとき
  • ダークモードを切り替えたいとき
  • ごみ箱を空にしたいとき
jacklandrin/OnlySwitch6,0012026年10月21日 更新

swift-concurrency-pro

無料概要あり

Swiftの非同期・並行処理をレビューし、共有データの扱い、タスクの構成、キャンセルなどを点検。問題箇所と修正前後のコード、対応の優先順位を示します。

  • actorと共有データの扱いを確認
  • タスク構成とキャンセル処理の点検
  • 厳格な並行処理チェックのエラー調査
jacklandrin/OnlySwitch6,0012026年10月21日 更新

swiftui-pro

無料概要あり

SwiftUIのコードを読み、古いAPIやデータの受け渡し、画面構成、操作のしやすさ、性能を点検。問題のある箇所と修正前後のコードをファイル別に示します。

  • 既存のSwiftUIコードをレビュー
  • 非推奨APIを更新したいとき
  • 読み上げや文字サイズへの対応確認
jacklandrin/OnlySwitch6,0012026年10月21日 更新

writing-plans

無料概要あり

仕様や要件を、変更ファイル・実装コード・テスト手順まで含む実装計画にまとめます。作業を小さく分け、コードを書き始める前の準備や引き継ぎに使えます。

  • 実装前に開発計画を立てたいとき
  • 開発作業の引き継ぎ
  • 要件を検証可能なタスクに分けたいとき
jacklandrin/OnlySwitch6,0012026年10月21日 更新

jacklandrin のスキルをすべて見る

このスキルの問題を報告する