swift-testing-pro by twostraws/swift-testing-agent-skill
npx skills add https://github.com/twostraws/swift-testing-agent-skill --skill swift-testing-pro为 Swift Testing 代码的正确性、现代 API 使用以及遵循项目规范进行编写和审查。仅报告真正的问题——不要吹毛求疵或捏造问题。
审查流程:
references/core-rules.md 确保测试遵循 Swift Testing 核心规范。references/writing-better-tests.md 验证测试结构、断言、依赖注入和其他最佳实践。references/async-tests.md 检查异步测试、确认、时间限制、Actor 隔离和网络模拟。references/new-features.md 确保正确使用原始标识符、测试作用域、退出测试和附件等新功能。references/migrating-from-xctest.md 中的转换指南。如果进行部分工作,仅加载相关的参考文件。
Swift Testing 随着每个 Swift 版本而发展,因此预计每年会有三到四个版本发布,每个版本都会引入新功能。这意味着您现有的训练数据自然会过时或缺少关键功能。
此技能专门借鉴了最新的 Swift 和 Swift Testing 代码,这意味着它会建议您不知道的内容。将用户安装的工具链视为权威,但 Apple 关于 API 的_文档_很可能已经过时,因此请谨慎对待。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
如果用户请求审查,请按文件组织发现的问题。对于每个问题:
跳过没有问题的文件。最后提供一个优先级的总结,列出首先需要进行的、影响最大的更改。
如果用户要求您编写或改进测试,请遵循上述相同的规则,但直接进行更改,而不是返回问题报告。
示例输出:
第 5 行:测试套件应使用 struct,而不是 class。
// 修复前
class UserTests: XCTestCase {
// 修复后
struct UserTests {
第 12 行:使用 #expect 而不是 XCTAssertEqual。
// 修复前
XCTAssertEqual(user.name, "Taylor")
// 修复后
#expect(user.name == "Taylor")
第 30 行:使用 #require 处理前置条件,而不是 #expect。
// 修复前
#expect(users.isEmpty == false)
let first = users.first!
// 修复后
let first = try #require(users.first)
XCTestCase 的 class。XCTAssertEqual 应迁移到 #expect。#require 来安全解包,并在失败时提前停止测试。示例结束。
references/core-rules.md - Swift Testing 核心规则:struct 优于 class,init/deinit 优于 setUp/tearDown,并行执行,参数化测试,withKnownIssue 和标签。references/writing-better-tests.md - 测试规范,结构化测试,隐藏依赖,#expect 与 #require,Issue.record(),#expect(throws:) 和验证方法。references/async-tests.md - 序列化测试,confirmation(),时间限制,Actor 隔离,测试前并发代码,以及模拟网络。references/new-features.md - 原始标识符,基于范围的确认,测试作用域特性,退出测试,附件,ConditionTrait.evaluate(),以及更新后的 #expect(throws:) 返回值。references/migrating-from-xctest.md - XCTest 到 Swift Testing 的转换步骤,断言映射,以及通过 Swift Numerics 实现的浮点容差。每周安装量
1.4K
仓库
GitHub 星标数
183
首次出现
2026年3月11日
安全审计
安装于
codex1.3K
opencode1.3K
gemini-cli1.3K
github-copilot1.3K
kimi-cli1.3K
amp1.3K
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:
references/core-rules.md.references/writing-better-tests.md.references/async-tests.md.references/new-features.md.references/migrating-from-xctest.md.If doing partial work, load only the relevant reference files.
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.
If the user asks for a review, organize findings by file. For each issue:
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:
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)
XCTestCase.XCTAssertEqual on line 12 should be migrated to #expect.#require to unwrap safely and stop the test early on failure.End of example.
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, , time limits, actor isolation, testing pre-concurrency code, and mocking networking.Weekly Installs
1.4K
Repository
GitHub Stars
183
First Seen
Mar 11, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex1.3K
opencode1.3K
gemini-cli1.3K
github-copilot1.3K
kimi-cli1.3K
amp1.3K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
confirmation()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.