guide-swift-testing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGuide 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
审查流程
- Ensure tests follow core conventions using .
references/core-rules.md - Validate structure, assertions, dependency injection, and best practices using .
references/writing-better-tests.md - Check async tests, confirmations, time limits, actor isolation, and networking mocks using .
references/async-tests.md - Ensure new features like raw identifiers, exit tests, and attachments are used correctly using .
references/new-features.md - If migrating from XCTest, follow .
references/migrating-from-xctest.md
If doing partial work, load only the relevant reference files.
- 使用确保测试遵循核心约定。
references/core-rules.md - 使用验证结构、断言、依赖注入和最佳实践。
references/writing-better-tests.md - 使用检查异步测试、确认机制、时间限制、Actor隔离和网络模拟。
references/async-tests.md - 使用确保新功能(如原始标识符、退出测试和附件)的使用正确。
references/new-features.md - 如果从XCTest迁移,请遵循的指引。
references/migrating-from-xctest.md
如果仅处理部分工作,只需加载相关的参考文件即可。
References
参考资料
| Topic | Reference |
|---|---|
Structs over classes, | |
Test hygiene, structure, DI, | |
Serialized tests, | |
| Raw identifiers, exit tests, attachments, test scoping traits, range-based confirmations | |
| XCTest-to-Swift Testing conversion, assertion mappings, floating-point tolerance | |
| 主题 | 参考文件 |
|---|---|
优先使用结构体而非类、 | |
测试规范、结构、依赖注入(DI)、 | |
序列化测试、 | |
| 原始标识符、退出测试、附件、测试范围特征、基于范围的确认 | |
| XCTest转Swift Testing的转换、断言映射、浮点容差 | |