AgentSkillsCN

xcode-test-analysis

分析xcresult包,深入洞察测试失败、测试运行缓慢以及可能存在不稳定性的测试案例。当用户询问测试结果、测试失败、测试运行缓慢或测试覆盖率时,可使用此技能。

SKILL.md
--- frontmatter
name: xcode-test-analysis
description: Analyzes xcresult bundles to provide insights on test failures, slow tests, and potentially flaky tests. Use when user asks about test results, test failures, slow tests, or test coverage.
disable-model-invocation: true
argument-hint: [path/to/Test.xcresult]
allowed-tools: Bash(swift:*,xcrun:*), Read

Xcode Test Analysis

Parses .xcresult bundles to provide detailed test insights.

When to Use

  • User asks "why did my tests fail?"
  • User wants to identify slow tests
  • User suspects flaky tests
  • User wants test coverage information

Usage

bash
swift ~/.claude/plugins/xcode-dx-skills/skills/xcode-test-analysis/scripts/parse-xcresult.swift /path/to/Test.xcresult

Or invoke directly:

code
/xcode-test-analysis path/to/Test.xcresult

Finding xcresult Bundles

xcresult bundles are typically located at:

code
~/Library/Developer/Xcode/DerivedData/<project>/Logs/Test/

Or run tests with explicit result bundle path:

bash
xcodebuild test -scheme MyApp -resultBundlePath ./TestResults.xcresult

What Gets Analyzed

MetricDescription
Failed testsTest names, failure messages, file/line
Slow testsTests exceeding duration threshold
Test durationTiming for each test case
Flaky candidatesTests with inconsistent results (if multiple runs available)
CoverageCode coverage percentage (if enabled)

Output Format

The script outputs JSON with:

  • summary: Pass/fail counts, total duration
  • failures: Detailed failure information with messages
  • slow_tests: Tests sorted by duration
  • by_suite: Results grouped by test suite
  • coverage: Coverage data if available