mcpField
A
axiom-testing

axiom-testing

github.com/charleswiltgen测试与质量1.2k1.3k 次安装今天更新
代码仓库

关于 axiom-testing

axiom-testing 是面向 Claude Code 的 Swift 测试技能,可将问题引导至对应指南和 Agent,涵盖单元、异步、UI 与自动化测试,并提供失败分析和质量审查路径。

主要功能

  1. 01Swift Testing 与 XCTest 指南
  2. 02异步和回调测试模式
  3. 03UI 与 XCUITest 工作流
  4. 04测试计划与 CI 指引
  5. 05不稳定测试分析与质量审查

适用场景

  1. 01选择 Swift Testing 或 XCTest
  2. 02排查不稳定的 UI 或异步测试
  3. 03在无模拟器时加快测试
  4. 04审查覆盖范围与测试可靠性

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/charleswiltgen/axiom --skill axiom-testing

安装后在 Claude Code 中输入/axiom-testing确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

skills/
swift-testing.md
test-failure-analyzer.md
testing-async.md
testing-auditor.md
ui-recording.md
ui-testing.md
xctest-automation.md

详细介绍

测试

对于任何与测试相关的问题,都必须使用此技能,包括编写测试、调试测试失败、提高测试速度或选择测试方法。

**Claude Code 随附的工具:**如果 command -v <tool> 没有找到任何内容(钩子已关闭或使用了 --bare),请使用 <plugin-root>/tools/<tool> 代替裸名称;<plugin-root> 是此技能中 Base directory for this skill: 路径向上两级的目录。

无法启动 Axiom Agent? 如果此路由器将你指向某个 Agent,请直接按照其流程操作。通过 MCP,axiom_get_agent 会返回该流程;在其他情况下,请读取下面的文件,只需搜索和读取文件即可。

此处可用:skills/test-failure-analyzer.md、skills/testing-auditor.md。

对于任何其他 Agent,通过 MCP,axiom_get_agent 也会返回其流程;请使用 axiom_xclog_*、axiom_xcsym_* 和 axiom_xcprof_* 工具执行其 xclog、xcsym 和 xcprof 步骤。在其他情况下,请在 Axiom 的技能中搜索 skills/<agent>.md;如果没有该文件,请使用此套件的技能自行完成工作,并使用 PATH 中的任意 Axiom 工具。

快速参考

症状 / 任务参考
编写单元测试、Swift Testing(@Test、#expect)参见 skills/swift-testing.md
让测试在不使用模拟器的情况下运行参见 skills/swift-testing.md
参数化测试、标签、特征参见 skills/swift-testing.md
从 XCTest 迁移到 Swift Testing参见 skills/swift-testing.md
警告级别的问题 / 取消测试 — Issue.record(severity:)、Test.cancel(OS27)参见 skills/swift-testing.md
测试 async/await 函数参见 skills/testing-async.md
针对回调的 confirmation参见 skills/testing-async.md
@MainActor 测试、并行执行参见 skills/testing-async.md
编写 UI 测试、XCUITest参见 skills/ui-testing.md
在 UI 测试中驱动 VoiceOver、断言朗读输出(OS27)参见 skills/ui-testing.md 模式 7
通过系统测试 App Intents、AppIntentsTesting(OS27)先参见 skills/ui-testing.md 模式 8,然后参见 axiom-integration(skills/app-intents-ref.md)
基于条件的等待模式参见 skills/ui-testing.md
录制 UI 自动化(Xcode 26)参见 skills/ui-testing.md
网络条件模拟、多因素测试参见 skills/ui-testing.md
测试可调整大小的应用:尺寸矩阵、RTL/伪本地化启动参数、实时调整大小测试参见 skills/ui-testing.md
从 CI 测试 Face ID/Touch ID、方向或模拟器状态 — devicectl参见 skills/ui-testing.md
XCUIElement 查询、等待策略参见 skills/xctest-automation.md
辅助功能标识符、测试计划参见 skills/xctest-automation.md
CI/CD 测试执行参见 skills/xctest-automation.md
录制/回放/审查工作流(Xcode 26)参见 skills/ui-recording.md
测试计划多配置回放参见 skills/ui-recording.md
增强录制的测试以提高稳定性参见 skills/ui-recording.md
测试生成式 AI 功能 — 输出并非确定,因此 #expect(result == expected) 不成立(OS27)先参见 axiom-ai(skills/foundation-models-evaluations.md)了解测试规范,然后参见 axiom-ai(skills/foundation-models-evaluations-ref.md)了解 API

决策树

digraph testing {
    start [label="Testing task" shape=ellipse];
    what [label="What kind of test?" shape=diamond];

    start -> what;
    what -> "skills/swift-testing.md" [label="unit tests,\nSwift Testing,\nfast tests"];
    what -> "skills/testing-async.md" [label="testing async code,\ncallbacks,\nconfirmation"];
    what -> "skills/ui-testing.md" [label="UI tests,\nflaky tests,\nrecording"];
    what -> "skills/xctest-automation.md" [label="XCUITest patterns,\nelement queries"];
    what -> "skills/ui-recording.md" [label="Xcode 26\nRecord/Replay/Review"];
    what -> "axiom-ai (skills/foundation-models-evaluations.md)" [label="generative AI feature\n(nondeterministic output)"];
}
  1. 编写单元测试 / 使用 Swift Testing?→ skills/swift-testing.md
  2. 测试 async/await 代码?→ skills/testing-async.md
  3. 编写 UI 测试 / XCUITest / 处理不稳定的测试?→ skills/ui-testing.md
  4. XCUIElement 查询、等待、测试计划、CI?→ skills/xctest-automation.md
  5. 录制 UI 交互(Xcode 26)?→ skills/ui-recording.md
  6. Swift Testing 中的不稳定测试 / 竞态条件?→ test-failure-analyzer(Agent)
  7. 测试崩溃 / 环境不正确?→ 参见 axiom-build(skills/xcode-debugging.md)
  8. 从 CLI 运行测试 / 解析结果?→ test-runner(Agent)
  9. 自动修复失败的测试?→ test-debugger(Agent)
  10. 想要审查测试质量?→ testing-auditor(Agent)或 /axiom:audit testing
  11. 不使用 XCUITest / AXe CLI 进行自动化?→ simulator-tester(Agent)+ 参见 axiom-xcode-mcp(skills/axe-ref.md)
  12. 测试 Foundation Models / 生成式功能?→ 先参阅 axiom-ai(skills/foundation-models-evaluations.md),了解评估规范(数据集设计、护栏与优化目标的区别、评估器校准),然后参阅 axiom-ai(skills/foundation-models-evaluations-ref.md)了解 API。Evaluations 框架(OS27)通过 .evaluates 特征在 Swift Testing 内部运行,并不取代它。模型并非纯函数,因此应针对数据集对输出评分,并依据聚合指标进行判断,而不是断言某个精确字符串。

Swift Testing 与 XCTest 快速指南

需求使用
单元测试(逻辑、模型)Swift Testing
UI 测试(点击、滑动、断言屏幕)XCUITest(XCTest)
通过系统运行 App Intents(AppIntentsTesting)使用 XCTest 的 UI Testing Bundle。Swift Testing 仅在使用未公开的构建设置覆盖项时才能在此运行
不使用模拟器的测试Package/Framework(任一框架)
参数化测试Swift Testing
性能测量XCTest(XCTMetric)
Objective-C 测试XCTest

关键模式

Swift Testing(skills/swift-testing.md):

  • @Test/@Suite 宏、#expect/#require 断言
  • 使用参数化测试消除重复测试
  • 快速测试架构:提取 Package,Host Application:None
  • 使用 withMainSerialExecutor 和 TestClock 进行可靠的异步测试
  • 从 XCTest 迁移指南(对比表)
  • XCTestCase 与 Swift 6.2 MainActor 的兼容性修复

异步测试(skills/testing-async.md):

  • 使用 confirmation 验证单个 / 多个回调
  • 使用 expectedCount: 0 验证某件事绝不会发生
  • @MainActor 测试隔离
  • 使用 .timeLimit 控制超时
  • 并行执行的注意事项和 .serialized

UI 测试(skills/ui-testing.md):

  • 基于条件的等待(替代 sleep())
  • 录制 UI 自动化(Xcode 26)
  • 用于 3G/LTE 测试的网络条件模拟
  • 多因素测试(设备尺寸 + 网络速度)
  • 调试 UI 测试失败导致的崩溃

XCUITest 自动化(skills/xctest-automation.md):

  • 使用 accessibilityIdentifier 标识元素
  • 等待策略(出现、消失、可交互)
  • 用于多配置测试的测试计划
  • 通过并行执行集成 CI/CD

UI 录制(skills/ui-recording.md):

  • Xcode 26 的 Record/Replay/Review 工作流
  • 优化录制代码,提升稳定性
  • 查询选择指南
  • 多语言回放的测试计划配置

自动扫描

测试质量审查 → 启动 testing-auditor Agent 或运行 /axiom:audit testing(将测试覆盖情况与生产代码进行比对,检测不稳定模式和速度问题,找出未测试的关键路径,并评估整体测试健康状况)

不稳定测试分析 → 启动 test-failure-analyzer Agent(扫描 Swift Testing 中导致间歇性失败的模式:缺少 confirmation、共享可变状态、缺少 @MainActor)

反合理化

想法现实
“测试问题很简单,我不需要这个技能。”正确的模式可以避免测试债务。skills/swift-testing.md 中有可直接复制粘贴的解决方案。
“我对 XCTest 已经够熟了。”Swift Testing 在单元测试方面明显更好。文中还包含迁移指南。
“测试很慢,不过没关系。”快速测试有助于践行 TDD。skills/swift-testing.md 展示了如何在不使用模拟器的情况下运行测试。
“我用 sleep() 修复这个不稳定的测试。”sleep() 会让测试更慢,也更不稳定。skills/ui-testing.md 中介绍了基于条件的等待方式。
“我之后再添加测试。”实现完成后才编写测试,会遗漏边界情况。
“我通过断言模型返回了正确的字符串来测试 AI 功能。”模型不是纯函数——遇到同义词时,这个测试会失败,却会让流畅的谎言通过。对数据集进行评分,并根据汇总指标设置门槛:axiom-ai(skills/foundation-models-evaluations.md)。
“我试过了,AI 的输出看起来不错,所以已经测试过了。”手动试几个提示词既无法衡量效果,也无法发现回归。这正是 Evaluations 框架旨在弥补的空缺。

调用示例

用户:“如何用 Swift 编写单元测试?” → 阅读:skills/swift-testing.md

用户:“我的 UI 测试在 CI 中不稳定。” → 检查代码库:是否使用 XCUIApplication/XCUIElement?→ skills/ui-testing.md → 检查代码库:是否使用 @Test/#expect?→ test-failure-analyzer(Agent)

用户:“如何在不引入不稳定因素的情况下测试异步代码?” → 阅读:skills/testing-async.md

用户:“Swift Testing 中与 XCTestExpectation 等效的是什么?” → 阅读:skills/testing-async.md

用户:“我想让测试运行得更快。” → 阅读:skills/swift-testing.md(策略 1:提取 Package)

用户:“我应该使用 Swift Testing 还是 XCTest?” → 阅读:skills/swift-testing.md(迁移部分)+ 此决策树

用户:“如何在 Xcode 26 中录制 UI 自动化?” → 阅读:skills/ui-recording.md

用户:“运行我的测试,并告诉我哪些失败了。” → 调用:test-runner(Agent)

用户:“审查我的测试,找出质量问题。” → 调用:testing-auditor(Agent)

评论

支持 Markdown