axiom-ios-testing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

iOS Testing Router

iOS测试场景路由指引

You MUST use this skill for ANY testing-related question, including writing tests, debugging test failures, making tests faster, or choosing between testing approaches.
任何与测试相关的问题都必须使用此技能,包括编写测试、调试测试失败、提升测试速度,或是选择测试方案。

When to Use

适用场景

Use this router when you encounter:
  • Writing new unit tests or UI tests
  • Swift Testing framework (@Test, #expect, @Suite)
  • XCTest or XCUITest questions
  • Making tests run faster (without simulator)
  • Flaky tests (pass sometimes, fail sometimes)
  • Testing async code reliably
  • Migrating from XCTest to Swift Testing
  • Test architecture decisions
  • Condition-based waiting patterns
当你遇到以下情况时,请使用此路由:
  • 编写新的单元测试或UI测试
  • Swift Testing框架(@Test、#expect、@Suite)相关问题
  • XCTest或XCUITest相关问题
  • 提升测试运行速度(无需模拟器)
  • 不稳定测试(时而通过,时而失败)
  • 可靠地测试异步代码
  • 从XCTest迁移到Swift Testing
  • 测试架构决策
  • 基于条件的等待模式

Routing Logic

路由逻辑

This router invokes specialized skills based on the specific testing need:
此路由会根据具体的测试需求调用专门的技能:

1. Unit Tests / Fast Tests → swift-testing

1. 单元测试 / 快速测试 → swift-testing

Triggers:
  • Writing new unit tests
  • Swift Testing framework (
    @Test
    ,
    #expect
    ,
    #require
    ,
    @Suite
    )
  • Making tests run without simulator
  • Testing async code reliably
  • withMainSerialExecutor
    ,
    TestClock
  • Migrating from XCTest
  • Parameterized tests
  • Tags and traits
  • Host Application: None configuration
  • Swift Package tests (
    swift test
    )
Why swift-testing: Modern Swift Testing framework with parallel execution, better async support, and the ability to run without launching simulator.
Invoke: Read the
axiom-swift-testing
skill

触发条件
  • 编写新的单元测试
  • Swift Testing框架(
    @Test
    #expect
    #require
    @Suite
  • 无需模拟器运行测试
  • 可靠地测试异步代码
  • withMainSerialExecutor
    TestClock
  • 从XCTest迁移
  • 参数化测试
  • 标签和特性
  • 主机应用:无配置
  • Swift Package测试(
    swift test
选择swift-testing的原因:现代Swift Testing框架支持并行执行、更好的异步处理,并且无需启动模拟器即可运行。
调用方式:查看
axiom-swift-testing
技能

2. UI Tests / XCUITest → ui-testing

2. UI测试 / XCUITest → ui-testing

Triggers:
  • Recording UI Automation (Xcode 26)
  • XCUIApplication, XCUIElement
  • Flaky UI tests
  • Tests pass locally, fail in CI
  • sleep()
    or arbitrary timeouts
  • Condition-based waiting
  • Cross-device testing
  • Accessibility-first testing
Why ui-testing: XCUITest requires simulator and has unique patterns for reliability.
Invoke: Read the
axiom-ui-testing
skill

触发条件
  • 录制UI自动化(Xcode 26)
  • XCUIApplication、XCUIElement
  • 不稳定的UI测试
  • 本地测试通过,但CI中失败
  • 使用
    sleep()
    或任意超时
  • 基于条件的等待
  • 跨设备测试
  • 优先考虑可访问性的测试
选择ui-testing的原因:XCUITest需要模拟器,并且有独特的可靠性模式。
调用方式:查看
axiom-ui-testing
技能

3. Flaky Tests / Race Conditions → test-failure-analyzer (Agent)

3. 不稳定测试 / 竞态条件 → test-failure-analyzer(Agent)

Triggers:
  • Tests fail randomly in CI
  • Tests pass locally but fail in CI
  • Flaky tests (pass sometimes, fail sometimes)
  • Race conditions in Swift Testing
  • Missing
    await confirmation
    for async callbacks
  • Missing
    @MainActor
    on UI tests
  • Shared mutable state in
    @Suite
  • Tests pass individually, fail when run together
Why test-failure-analyzer: Specialized agent that scans for patterns causing intermittent failures in Swift Testing.
Invoke: Launch
test-failure-analyzer
agent

触发条件
  • CI中测试随机失败
  • 本地测试通过,但CI中失败
  • 不稳定测试(时而通过,时而失败)
  • Swift Testing中的竞态条件
  • 异步回调缺少
    await confirmation
  • UI测试缺少
    @MainActor
  • @Suite
    中的共享可变状态
  • 单独运行测试通过,一起运行则失败
选择test-failure-analyzer的原因:专门的Agent,用于扫描Swift Testing中导致间歇性失败的模式。
调用方式:启动
test-failure-analyzer
Agent

4. Async Testing Patterns → testing-async

4. 异步测试模式 → testing-async

Triggers:
  • Testing async/await functions
  • confirmation
    for callbacks (Swift Testing)
  • expectedCount
    for multiple callbacks
  • Testing MainActor code with
    @MainActor @Test
  • Migrating XCTestExpectation → confirmation
  • Parallel test execution concerns
  • Test timeout configuration
Why testing-async: Dedicated patterns for async code in Swift Testing framework.
Invoke: Read the
axiom-testing-async
skill

触发条件
  • 测试async/await函数
  • Swift Testing中用于回调的
    confirmation
  • 多回调的
    expectedCount
  • 使用
    @MainActor @Test
    测试MainActor代码
  • 从XCTestExpectation迁移到confirmation
  • 并行测试执行相关问题
  • 测试超时配置
选择testing-async的原因:针对Swift Testing框架中的异步代码提供专门的模式。
调用方式:查看
axiom-testing-async
技能

5. Test Crashes / Environment Issues → xcode-debugging

5. 测试崩溃 / 环境问题 → xcode-debugging

Triggers:
  • Tests crash before assertions run
  • Simulator won't boot for tests
  • Tests hang indefinitely
  • "Unable to boot simulator" errors
  • Clean test run differs from incremental
Why xcode-debugging: Test failures from environment issues, not test logic.
Invoke: Read the
axiom-xcode-debugging
skill

触发条件
  • 断言执行前测试崩溃
  • 模拟器无法启动以运行测试
  • 测试无限挂起
  • "无法启动模拟器"错误
  • 清理后的测试运行与增量运行结果不同
选择xcode-debugging的原因:测试失败源于环境问题,而非测试逻辑。
调用方式:查看
axiom-xcode-debugging
技能

6. Running XCUITests from Command Line → test-runner (Agent)

6. 从命令行运行XCUITests → test-runner(Agent)

Triggers:
  • Run tests with xcodebuild
  • Parse xcresult bundles
  • Export failure screenshots/videos
  • Code coverage reports
  • CI/CD test execution
Why test-runner: Specialized agent for command-line test execution with xcresulttool parsing.
Invoke: Launch
test-runner
agent

触发条件
  • 使用xcodebuild运行测试
  • 解析xcresult包
  • 导出失败截图/视频
  • 代码覆盖率报告
  • CI/CD测试执行
选择test-runner的原因:专门的Agent,用于命令行测试执行及xcresulttool解析。
调用方式:启动
test-runner
Agent

7. Closed-Loop Test Debugging → test-debugger (Agent)

7. 闭环测试调试 → test-debugger(Agent)

Triggers:
  • Fix failing tests automatically
  • Debug persistent test failures
  • Run → analyze → fix → verify cycle
  • Need to iterate until tests pass
  • Analyze failure screenshots
Why test-debugger: Automated cycle of running tests, analyzing failures, suggesting fixes, and re-running.
Invoke: Launch
test-debugger
agent

触发条件
  • 自动修复失败的测试
  • 调试持续失败的测试
  • 运行→分析→修复→验证循环
  • 需要迭代直到测试通过
  • 分析失败截图
选择test-debugger的原因:自动化的测试运行、失败分析、修复建议及重新运行循环。
调用方式:启动
test-debugger
Agent

8. Recording UI Automation (Xcode 26) → ui-recording

8. 录制UI自动化(Xcode 26)→ ui-recording

Triggers:
  • Record user interactions in Xcode
  • Test plans for multi-config replay
  • Video review of test runs
  • Xcode 26 recording workflow
  • Enhancing recorded test code
Why ui-recording: Focused guide for Xcode 26's Record/Replay/Review workflow.
Invoke: Read the
axiom-ui-recording
skill

触发条件
  • 在Xcode中录制用户交互
  • 用于多配置重放的测试计划
  • 测试运行的视频回顾
  • Xcode 26录制工作流
  • 优化录制的测试代码
选择ui-recording的原因:针对Xcode 26的录制/重放/回顾工作流的专属指南。
调用方式:查看
axiom-ui-recording
技能

9. UI Automation Without XCUITest → simulator-tester + axe-ref

9. 不使用XCUITest的UI自动化 → simulator-tester + axe-ref

Triggers:
  • Automate app without test target
  • AXe CLI usage (tap, swipe, type)
  • describe-ui for accessibility tree
  • Quick automation outside XCUITest
  • Scripted simulator interactions
Why simulator-tester + axe-ref: AXe provides accessibility-based UI automation when XCUITest isn't available.
Invoke: Launch
simulator-tester
agent (uses axiom-axe-ref)

触发条件
  • 无需测试目标即可自动化应用
  • AXe CLI使用(点击、滑动、输入)
  • describe-ui用于可访问性树
  • XCUITest之外的快速自动化
  • 脚本化的模拟器交互
选择simulator-tester + axe-ref的原因:当无法使用XCUITest时,AXe提供基于可访问性的UI自动化。
调用方式:启动
simulator-tester
Agent(使用axiom-axe-ref)

Decision Tree

决策树

  1. Writing unit tests / Swift Testing? → swift-testing
  2. Writing UI tests / XCUITest? → ui-testing
  3. Testing async/await code? → testing-async
  4. Flaky tests / race conditions (XCUITest)? → ui-testing
  5. Flaky tests / race conditions (Swift Testing)? → test-failure-analyzer (Agent)
  6. Tests crash / environment wrong? → xcode-debugging (via ios-build)
  7. Tests are slow? → swift-testing (Fast Tests section)
  8. Run tests from CLI / parse results? → test-runner (Agent)
  9. Fix failing tests automatically? → test-debugger (Agent)
  10. Record UI interactions (Xcode 26)? → ui-recording
  11. Automate without XCUITest / AXe CLI? → simulator-tester + axe-ref
  1. 编写单元测试 / 使用Swift Testing?→ swift-testing
  2. 编写UI测试 / 使用XCUITest?→ ui-testing
  3. 测试async/await代码?→ testing-async
  4. 不稳定测试 / 竞态条件(XCUITest)?→ ui-testing
  5. 不稳定测试 / 竞态条件(Swift Testing)?→ test-failure-analyzer(Agent)
  6. 测试崩溃 / 环境异常?→ xcode-debugging(通过ios-build)
  7. 测试速度慢?→ swift-testing(快速测试章节)
  8. 从CLI运行测试 / 解析结果?→ test-runner(Agent)
  9. 自动修复失败的测试?→ test-debugger(Agent)
  10. 录制UI交互(Xcode 26)?→ ui-recording
  11. 不使用XCUITest进行自动化 / 使用AXe CLI?→ simulator-tester + axe-ref

Swift Testing vs XCTest Quick Guide

Swift Testing与XCTest快速指南

NeedUse
Unit tests (logic, models)Swift Testing
UI tests (tap, swipe, assert screens)XCUITest (XCTest)
Tests without simulatorSwift Testing + Package/Framework
Parameterized testsSwift Testing
Performance measurementsXCTest (XCTMetric)
Objective-C testsXCTest
需求选择
单元测试(逻辑、模型)Swift Testing
UI测试(点击、滑动、断言界面)XCUITest(XCTest)
无需模拟器运行测试Swift Testing + Package/Framework
参数化测试Swift Testing
性能测量XCTest(XCTMetric)
Objective-C测试XCTest

Anti-Rationalization

误区纠正

ThoughtReality
"Simple test question, I don't need the skill"Proper patterns prevent test debt. swift-testing has copy-paste solutions.
"I know XCTest well enough"Swift Testing is significantly better for unit tests. swift-testing covers migration.
"Tests are slow but it's fine"Fast tests enable TDD. swift-testing shows how to run without simulator.
"I'll fix the flaky test with a sleep()"sleep() makes tests slower AND flakier. ui-testing has condition-based waiting patterns.
"I'll add tests later"Tests written after implementation miss edge cases. swift-testing makes writing tests first easy.
想法实际情况
"简单的测试问题,我不需要这个技能"正确的模式可以避免测试债务。swift-testing提供了可直接复制的解决方案。
"我对XCTest足够熟悉了"Swift Testing在单元测试方面明显更优。swift-testing涵盖了迁移内容。
"测试速度慢但没关系"快速测试支持TDD。swift-testing展示了如何无需模拟器运行测试。
"我用sleep()来修复不稳定测试"sleep()会让测试更慢且更不稳定。ui-testing提供了基于条件的等待模式。
"我之后再写测试"实现后再写测试会遗漏边缘情况。swift-testing让先写测试变得简单。

Example Invocations

调用示例

User: "How do I write a unit test in Swift?" → Invoke: axiom-swift-testing
User: "My UI tests are flaky in CI" → Check codebase: XCUIApplication/XCUIElement patterns? → ui-testing → Check codebase: @Test/#expect patterns? → test-failure-analyzer
User: "Tests fail randomly, pass sometimes fail sometimes" → Invoke: test-failure-analyzer (Agent)
User: "Tests pass locally but fail in CI" → Invoke: test-failure-analyzer (Agent)
User: "How do I test async code without flakiness?" → Invoke: testing-async
User: "How do I test callback-based APIs with Swift Testing?" → Invoke: testing-async
User: "What's the Swift Testing equivalent of XCTestExpectation?" → Invoke: testing-async
User: "How do I use confirmation with expectedCount?" → Invoke: testing-async
User: "I want my tests to run faster" → Invoke: axiom-swift-testing (Fast Tests section)
User: "Should I use Swift Testing or XCTest?" → Invoke: axiom-swift-testing (Migration section) + this decision tree
User: "Tests crash before any assertions" → Invoke: axiom-xcode-debugging
User: "Run my tests and show me what failed" → Invoke: test-runner (Agent)
User: "Help me fix these failing tests" → Invoke: test-debugger (Agent)
User: "Parse the xcresult from my last test run" → Invoke: test-runner (Agent)
User: "Export failure screenshots from my tests" → Invoke: test-runner (Agent)
User: "How do I record UI automation in Xcode 26?" → Invoke: axiom-ui-recording
User: "How do I use test plans for multi-language testing?" → Invoke: axiom-ui-recording
User: "Can I automate my app without writing XCUITests?" → Invoke: simulator-tester (Agent) + axiom-axe-ref
User: "How do I tap a button using AXe?" → Invoke: axiom-axe-ref (via simulator-tester)
用户:"我如何用Swift编写单元测试?" → 调用:axiom-swift-testing
用户:"我的UI测试在CI中不稳定" → 检查代码库:是否使用XCUIApplication/XCUIElement模式?→ ui-testing → 检查代码库:是否使用@Test/#expect模式?→ test-failure-analyzer
用户:"测试随机失败,时而通过时而失败" → 调用:test-failure-analyzer(Agent)
用户:"本地测试通过,但CI中失败" → 调用:test-failure-analyzer(Agent)
用户:"如何无不稳定地测试异步代码?" → 调用:testing-async
用户:"如何用Swift Testing测试基于回调的API?" → 调用:testing-async
用户:"Swift Testing中与XCTestExpectation等效的是什么?" → 调用:testing-async
用户:"如何使用带expectedCount的confirmation?" → 调用:testing-async
用户:"我想让我的测试运行得更快" → 调用:axiom-swift-testing(快速测试章节)
用户:"我应该用Swift Testing还是XCTest?" → 调用:axiom-swift-testing(迁移章节) + 本决策树
用户:"测试在任何断言执行前崩溃" → 调用:axiom-xcode-debugging
用户:"运行我的测试并告诉我哪些失败了" → 调用:test-runner(Agent)
用户:"帮我修复这些失败的测试" → 调用:test-debugger(Agent)
用户:"解析我上次测试运行的xcresult" → 调用:test-runner(Agent)
用户:"从我的测试中导出失败截图" → 调用:test-runner(Agent)
用户:"我如何在Xcode 26中录制UI自动化?" → 调用:axiom-ui-recording
用户:"我如何使用测试计划进行多语言测试?" → 调用:axiom-ui-recording
用户:"我可以不用编写XCUITests来自动化我的应用吗?" → 调用:simulator-tester(Agent) + axiom-axe-ref
用户:"我如何用AXe点击按钮?" → 调用:axiom-axe-ref(通过simulator-tester)