# Skill Test Spec: /test-flakiness ## Skill Summary `/test-flakiness` finds flaky tests from the results of multiple CI or local test runs. It takes a log path, `scan` (all available result files — JUnit XML from gdUnit4 in `reports/` or saved into `test-results/`, NUnit XML from Unity in `test-results/`, Unreal automation logs in `Saved/Logs/`), or `registry` (remediation guidance for tests already in the quarantine section of `tests/regression-suite.md`). With no result data it lists three ways to get some and stops to ask. It builds a per-test history across runs, classifies each test that both passed and failed by fail rate — >25% High (quarantine immediately), 5–25% Moderate (fix directly, do not quarantine yet), 1–5% Low (monitor) — and names a likely cause and fix direction from its cause table, using Grep on the test file. With fewer than 3 runs, every finding is "suspected", not "confirmed", whatever its fail rate, and nothing is quarantined; the summary table's Confidence column says which. It asks separately "May I update the quarantine section of `tests/regression-suite.md`…?" and "May I write a full flakiness report to `production/qa/flakiness-report-[date].md`?", appends quarantine entries without removing existing ones, and never deletes test files. No director gates are invoked. Verdicts: COMPLETE (report written) or BLOCKED (user declined write). --- ## Static Assertions (Structural) Checked against the SKILL.md by `/skill-test spec` — no fixture needed. - [ ] Has required frontmatter fields: `name`, `description`, `argument-hint`, `user-invocable`, `allowed-tools` - [ ] Has ≥2 phase headings - [ ] Contains verdict keywords: COMPLETE, BLOCKED, and the flakiness tiers High / Moderate / Low - [ ] Contains "May I" write language for `tests/regression-suite.md` and `production/qa/flakiness-report-[date].md` - [ ] Has a next-step handoff (Section 7: add skip annotations, schedule fixes before the release gate) --- ## Director Gate Checks None. Flakiness detection is an advisory quality skill; no gates are invoked. --- ## Test Cases ### Case 1: Happy Path — High flakiness from JUnit history, quarantined on approval **Fixture:** - `project.yaml`: `engine.name: godot`; `modes.automation` unset (collaborative) - `test-results/` holds 6 gdUnit4 JUnit XML files from 6 runs of the same commit - `test_loot_drop_rolls_rare_item` fails in 2 of the 6 runs (33%); the other 40 tests pass in all 6 - `tests/unit/loot/loot_drop_test.gd` calls `randf()` with no seed - `tests/regression-suite.md` has a Quarantined Tests table with 1 existing entry **Input:** `/test-flakiness scan` **Expected behavior:** 1. Skill finds the XML files in `test-results/` and parses `25% High (quarantine), 5–25% Moderate (fix, do not quarantine), 1–5% Low (monitor) - [ ] Names a likely cause and fix direction from the cause table, using Grep on the test file - [ ] Counts a test as flaky only when it both passed and failed across runs with no code change between them - [ ] With fewer than 3 runs, flags findings as suspected, not confirmed, in the summary's Confidence column, and quarantines nothing - [ ] Asks separately before updating `tests/regression-suite.md` and before writing `production/qa/flakiness-report-[date].md` - [ ] Appends quarantine entries, never removes existing ones, and never deletes test files - [ ] No director gates are invoked - [ ] Ends with COMPLETE on write or BLOCKED on decline; with no result data it lists the three options and stops to ask instead (Case 3), never reporting a clean result --- ## Coverage Notes - The no-argument path (run `scan` when CI logs are accessible, else `registry`) is not tested here. - Unity NUnit XML follows the same flow as Case 1, read from `}`), and its skip mechanism is NOT SOURCEABLE, so a quarantined Unreal test is logged and the user is asked how their CI excludes it. The same applies to gdUnit4 C# tests. - The Low tier (1–5%) needs 20 or more runs to reach and is not tested.