test-flakiness
它能做什么
这个技能会查看多次运行的自动化测试结果,找出时好时坏的测试。适合厌倦了不可靠红色构建的开发者和 QA 负责人。
适用场景
- ✓当团队有大量测试运行记录,怀疑某些测试会随机失败的时候。
- ✓当开发者开始把 CI 失败归咎于可能是不稳定测试的时候。
- ✓当被隔离的测试需要分析其可能原因的时候。
技能链接
https://github.com/Donchitos/Claude-Code-Game-Studios/blob/main/.claude/skills/test-flakiness/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请查看我们的 CI 日志,找出哪些测试不稳定,并告诉我应该隔离哪些。”
每周 5 个新技能,1 分钟读完。
工作原理
这个技能会读取 CI 日志文件,计算多次运行的通过率,并找出间歇性失败。它会为每个不稳定测试建议隔离还是修复,并可以保存报告。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
!bash "${CLAUDE_SKILL_DIR}/../../hooks/yaml-helper.sh" resolve_config --keys automation
Automation mode: Resolve modes.automation (project.local.yaml →
project.yaml → default collaborative). Every AskUserQuestion call and
every file write follows .claude/docs/automation-modes.md
(collaborative asks always · guided major-only · autonomous logs and proceeds;
automation_always_ask categories always prompt).
Test Flakiness Detection
A flaky test is one that sometimes passes and sometimes fails without any code change. Flaky tests are worse than no tests in some ways — they train the team to ignore red CI runs, masking genuine failures. This skill identifies them, explains likely causes, and recommends whether to quarantine or fix each one.
Output: Updated tests/regression-suite.md quarantine section + optional
production/qa/flakiness-report-[date].md
When to run:
- Polish phase (tests have had many runs; statistical signal is reliable)
- When developers start dismissing CI failures as "probably flaky"
- After
/regression-suiteidentifies quarantined tests that need diagnosis
1. Parse Arguments
Modes:
/test-flakiness [ci-log-path]— analyse a specific CI run log file/test-flakiness scan— scan all available CI logs in.github/or standard log output directories/test-flakiness registry— read existing regression-suite.md quarantine section and provide remediation guidance for already-known flaky tests- No argument — auto-detect: run
scanif CI logs are accessible, elseregistry
2. Locate CI Log Data
Option A — GitHub Actions (preferred)
Check for test result artifacts:
ls -t .github/ 2>/dev/null
ls -t test-results/ 2>/dev/null
For Godot projects: GdUnit4 outputs XML results compatible with JUnit format,
under reports/ (its default report folder, res://reports/). Check reports/,
and any test-results/ you saved runs into, for .xml files.
For Unity projects: game-ci test runner outputs NUnit XML to test-results/
by default.
For Unreal projects: automation logs go to Saved/Logs/. Grep for
Result={Success} and Result={Fail} — each test prints
Test Completed. Result={<status>}
(docs/engine-reference/unreal/current-best-practices.md, "Command Line").
Option B — Local log files
If a path argument is provided, read that file directly.
Option C — No log data available
If no logs found:
"No CI log data found. To detect flaky tests, this skill needs test result history from multiple runs. Options:
- Run the test suite at least 3 times and collect the output logs
- Check CI pipeline output and save a log to
test-results/- Run
/test-flakiness registryto review tests already flagged as flaky intests/regression-suite.md"
Stop and ask the user which option to pursue.
3. Parse Test Results
For each CI log or result file found, parse:
JUnit XML format (GdUnit4):
- Grep for
<testcase name=to get test names - Grep for
<failureor<errorto identify failures - Parse
classnameandnameattributes for full test identifiers
NUnit XML format (Unity — the file whose <test-run> element /smoke-check
reads):
- Each test is a
<test-caseelement; itsfullnameattribute is the identifier - Its
resultattribute isPassed,Failed,InconclusiveorSkipped(docs/engine-reference/unity/current-best-practices.md, "Command Line"); onlyPassedandFailedenter the history
Plain text logs:
- Grep for pass/fail patterns:
- Godot:
PASSED/FAILEDadjacent to test names - Unreal:
Result={Success}/Result={Fail} - Unity:
Test passed/Test failed
- Godot:
Build a table: test_id → [run1_result, run2_result, run3_result, ...]
4. Identify Flaky Tests
A test is flaky if it appears in the result history with both PASS and FAIL outcomes across runs with no code changes between them.
Flakiness thresholds:
- High flakiness: Fails in >25% of runs — quarantine immediately
- Moderate flakiness: Fails in 5–25% of runs — investigate and fix soon
- Low/suspected flakiness: Fails in 1–5% of runs — monitor; may be genuinely rare failure
With fewer than 3 runs, every finding is suspected, whatever its fail rate. One failure in two runs reads as 50%, but it is one data point: do not quarantine it, label it suspected, and ask whether more run data is available. The tiers above, and quarantine, apply from
常见问题
它需要很多次运行吗?
需要。它在多次运行之后效果最好,因为一次运行无法显示间歇性失败。
什么是隔离?
它是指把不稳定的测试移出主要结果,使它不再掩盖真正的失败。
它从哪里查找日志?
它可以分析你指定的一个日志文件,也可以扫描标准的 CI 日志文件夹。
详情
作者的原始描述
Find flaky tests from CI logs — aggregates pass rates, spots intermittent failures, recommends quarantine. After multiple runs.
热度
- GitHub 星标
- 33k
- 排名
- #8502
- 许可证
- MIT
- 更新时间
- 2026/10/18
评论
- …