跳到正文
Skillpedia
测试5.9k · #14542

compare-test-case

它能做什么

这项技能在两个分支之间比较单个自动化测试,判断某项改动是否破坏了它。适合追查测试退化或不稳定测试的开发者。

适用场景

  • ✓当功能分支上的某项工作完成后,某个测试开始失败时。
  • ✓当你想知道某个测试是否不稳定,以及它多久失败一次的时候。
  • ✓当你需要查看某个特定测试的失败细节以便调查的时候。

技能链接

https://github.com/tuist/tuist/blob/main/skills/skills/compare-test-case/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/tuist/tuist/blob/main/skills/skills/compare-test-case/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请比较我功能分支上的 LoginTests 测试用例和主分支,并告诉我它在该分支上为什么失败。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会查找该测试用例,列出它在每个分支上的运行记录,比较通过和失败结果及耗时,然后检查失败的运行以获取细节。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Compare Test Case

Quick Start

You'll typically receive a test case identifier and two branches. Follow these steps:

  1. Run tuist test case show <id-or-identifier> --json to get the test case metrics.
  2. Run tuist test case run list <identifier> --json to see runs across branches.
  3. Compare behavior between base and head branches.
  4. Inspect failures with tuist test case run show <run-id> --json.
  5. Summarize findings with root cause analysis.

Step 1: Resolve the Test Case

By ID or dashboard URL

tuist test case show <test-case-id> --json

By identifier (Module/Suite/TestCase)

tuist test case show Module/Suite/TestCase --json

If no test case is provided

Discover flaky or failing tests to investigate:

tuist test case list --flaky --json --page-size 10

Key fields from the response:

  • id -- unique identifier for subsequent commands
  • name, module_name, suite_name -- the test identity
  • reliability_rate -- percentage of successful runs
  • flakiness_rate -- percentage of flaky runs in the last 30 days
  • total_runs / failed_runs -- volume context
  • is_flaky / is_quarantined -- current flags

Step 2: Get Runs on Each Branch

List test case runs filtered by the test case, and look at the git_branch field:

tuist test case run list <identifier> --json --page-size 20

Separate runs by branch. For each branch, compute:

  • Pass rate: passed_runs / total_runs * 100
  • Average duration
  • Flaky run count
  • Most recent status

Defaults

  • If no base branch is provided, use the project's default branch (usually main).
  • If no head branch is provided, detect the current git branch.

Step 3: Compare Branch Behavior

Metric Base branch Head branch Verdict
Pass rate e.g. 100% e.g. 60% REGRESSION
Avg duration e.g. 0.5s e.g. 2.1s REGRESSION
Flaky runs 0 3 NEW FLAKINESS
Last status success failure REGRESSION

Classify the change:

  • Newly failing: 100% pass rate on base, <100% on head
  • Newly flaky: No flaky runs on base, flaky runs on head
  • Duration regression: >50% increase in average duration
  • Fixed: Failing on base, passing on head
  • Stable: Same behavior on both branches

Step 4: Inspect Failures

For each failing run on the head branch:

tuist test case run show <test-case-run-id> --json

Examine:

  • failures[].message -- the assertion or error message
  • failures[].path -- source file path
  • failures[].line_number -- exact line of failure
  • failures[].issue_type -- type of issue
  • repetitions -- shows retry behavior (e.g., pass-fail-pass means flaky)
  • crash_report -- crash data if the test runner crashed

Step 5: Identify Root Cause

Based on the comparison:

Newly failing

  • Check commits between base and head branches for changes to the test file or the code under test.
  • Look at the failure message for clues about what changed.

Newly flaky

  • Common patterns: timing/async issues, shared state, environment dependencies.
  • Check if repetitions show intermittent pass/fail patterns.
  • See the fix-flaky-tests skill for detailed flaky test analysis patterns.

Duration regression

  • Check if setup/teardown time increased.
  • Check if the test is doing more work (new assertions, larger data sets).
  • Check if a dependency became slower.

Summary Format

Produce a summary with:

  1. Test case info: Name, module, suite, overall reliability.
  2. Base branch behavior: Pass rate, avg duration, flaky count.
  3. Head branch behavior: Pass rate, avg duration, flaky count.
  4. Verdict: What changed and classification.
  5. Root cause: Hypothesis based on failure analysis.
  6. Recommendations: Specific file paths, line numbers, and fix suggestions.

Example:

Test Case Comparison: AuthModuleTests/LoginTests/test_login_with_expired_token

Overall reliability: 85% (was 100% before head branch)

Base (main):
  Pass rate: 100% (15/15 runs)
  Avg duration: 0.3s
  Flaky: No

Head (feature/auth-refactor):
  Pass rate: 60% (3/5 runs)
  Avg duration: 0.5s
  Flaky: Yes (2 flaky runs)

Verdict: NEWLY FLAKY -- test was stable on main but intermittently fails on feature branch

Root cause: The auth refactor introduced an async token refresh that races with the
test's synchronous assertion. Failures show "Expected status 401, got nil" at
Tests/AuthModuleTests/LoginTests.swift:42, suggesting the res
常见问题

它能找出不稳定的测试吗?

能。它可以列出不稳定的测试,并显示其可靠性和不稳定率。

如何识别一个测试用例?

可以通过它的 ID,或通过模块、套件和测试名称来找到它。

我需要 Tuist 吗?

需要。它通过 Tuist 命令行工具读取测试用例数据。

详情

作者的原始描述

Compares a single test case's behavior across two branches, analyzing pass/fail status, duration, flakiness, and failure details. Useful for investigating test regressions introduced by a feature branch.

repo: tuist/tuist

热度

GitHub 星标
5.9k
排名
#14542
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能