guide-swift-testing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Guide Skill — This is an expert workflow/pattern guide, not API reference documentation. Originally from twostraws/Swift-Testing-Agent-Skill by Paul Hudson. MIT License.
指南Skill —— 这是一份专家级工作流程/模式指南,而非API参考文档。 原文来自 Paul Hudson 的 twostraws/Swift-Testing-Agent-Skill。采用MIT许可证。

Swift Testing Patterns

Swift Testing 模式

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.
编写和审查Swift Testing代码,确保正确性、现代API使用以及符合项目约定。仅报告真实存在的问题——不要吹毛求疵或捏造问题。

Core Instructions

核心说明

  • Target Swift 6.2 or later, using modern Swift concurrency.
  • Swift Testing does not support UI tests — XCTest must be used there.
  • Do not rewrite existing XCTest to Swift Testing unless requested.
  • 目标版本为Swift 6.2或更高版本,使用现代Swift并发机制。
  • Swift Testing 不支持UI测试——此类场景必须使用XCTest。
  • 除非有明确要求,否则不要将现有XCTest重写为Swift Testing。

Review Process

审查流程

  1. Ensure tests follow core conventions using
    references/core-rules.md
    .
  2. Validate structure, assertions, dependency injection, and 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, exit tests, and attachments are used correctly using
    references/new-features.md
    .
  5. If migrating from XCTest, follow
    references/migrating-from-xctest.md
    .
If doing partial work, load only the relevant reference files.
  1. 使用
    references/core-rules.md
    确保测试遵循核心约定。
  2. 使用
    references/writing-better-tests.md
    验证结构、断言、依赖注入和最佳实践。
  3. 使用
    references/async-tests.md
    检查异步测试、确认机制、时间限制、Actor隔离和网络模拟。
  4. 使用
    references/new-features.md
    确保新功能(如原始标识符、退出测试和附件)的使用正确。
  5. 如果从XCTest迁移,请遵循
    references/migrating-from-xctest.md
    的指引。
如果仅处理部分工作,只需加载相关的参考文件即可。

References

参考资料

TopicReference
Structs over classes,
@Suite
, parallel execution,
withKnownIssue
, tags
references/core-rules.md
Test hygiene, structure, DI,
#expect
vs
#require
,
Issue.record()
, verification methods
references/writing-better-tests.md
Serialized tests,
confirmation()
, time limits, actor isolation, mocking networking
references/async-tests.md
Raw identifiers, exit tests, attachments, test scoping traits, range-based confirmations
references/new-features.md
XCTest-to-Swift Testing conversion, assertion mappings, floating-point tolerance
references/migrating-from-xctest.md
主题参考文件
优先使用结构体而非类、
@Suite
、并行执行、
withKnownIssue
、标签
references/core-rules.md
测试规范、结构、依赖注入(DI)、
#expect
vs
#require
Issue.record()
、验证方法
references/writing-better-tests.md
序列化测试、
confirmation()
、时间限制、Actor隔离、网络模拟
references/async-tests.md
原始标识符、退出测试、附件、测试范围特征、基于范围的确认
references/new-features.md
XCTest转Swift Testing的转换、断言映射、浮点容差
references/migrating-from-xctest.md