test-fixer
БесплатноБез исполняемых скриптовНе проверенAgent for diagnosing and fixing flaky terminal UI tests in the Hex1b test suite. Use when tests pass locally but fail in CI, or when tests exhibit…
от mitchdenny★ 186 звёзд на GitHubОб этом скилле
Test Fixer Skill
This skill provides guidelines for AI agents to diagnose and fix flaky tests in the Hex1b TUI library test suite. These tests use MSTest 4 (MSTest.Sdk/4.2.3, OutputType=Exe) with Microsoft.Testing.Platform and Hex1bTerminalInputSequenceBuilder to simulate user interactions with terminal applications. global.json configures dotnet test to use MTP, and test projects can also be run as executables with dotnet run --project tests/SomeProject/.
Quick Reference: Common Flaky Test Patterns
| Pattern | Symptom | Fix |
|---|---|---|
| Snapshot After Exit | Test passes locally, fails on Linux CI | Move WaitUntil before Capture, ensure Capture is before exit |
| Missing WaitUntil | Intermittent assertion failures | Add WaitUntil for expected state before Capture |
| Race with Ctrl+C | Snapshot missing expected content | Add WaitUntil between last action and Capture |
| Task.WhenAny Race | Test sometimes times out | Replace with proper WaitUntil or increase timeout |
| Test Interference | Pass isolated, fail in suite | Check for shared state, file locks, or parallel execution issues |
| Platform-Specific | Fails consistently on Windows/Linux | Add TestCategory/Ignore or fix platform-specific code |
| Task.Delay for Async Events | Flaky on slower CI runners | Replace Task.Delay with TaskCompletionSource signal |
| Helper Partial Wait | Tests using multi-line helpers fail intermittently | Wait for all/last content, not just first line |
Pattern 1: Snapshot Captured After App Exit
⚠️ This is the most common flaky test issue
Symptoms
- Test passes consistently on Windows
- Test fails on Linux CI (GitHub Actions ubuntu-latest)
- Assertion fails with content that "should" be there
- Error messages like
Assert.IsTrue failedorAn item should be selected with indicator
Root Cause
The ApplyWithCaptureAsync method returns terminal.CreateSnapshot() after all steps complete, not at the point where .Capture() is called. When the sequence includes Ctrl+C to exit the app, the terminal buffer may be cleared before the final snapshot is taken.
Platform difference: Windows terminal buffers persist longer after app exit; Linux clears them more aggressively.
Example: Broken Test
// ❌ BROKEN: Snapshot is taken AFTER Ctrl+C exits the app
var snapshot = await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Counter: 3"), TimeSpan.FromSeconds(2))
.Capture("final") // This saves SVG but doesn't capture for return!
.Ctrl().Key(Hex1bKey.C) // App exits, terminal buffer may be cleared
.Build()
.ApplyWithCaptureAsync(terminal, TestContext.Current.CancellationToken);
// snapshot is from AFTER Ctrl+C, not from Capture step!
Assert.IsTrue(snapshot.ContainsText("Counter: 3")); // May fail on Linux!
How It Works
Hex1bTerminalInputSequenceBuilderbuilds a sequence ofTestStepobjectsApplyWithCaptureAsyncexecutes all steps, then callsterminal.CreateSnapshot()at the endCaptureSteponly saves SVG/HTML files—it does NOT store the snapshot for return- When
Ctrl+Ctriggers app exit, the terminal may clear its buffer before the final snapshot
Fix Strategy
Option A: Ensure WaitUntil is immediately before Capture (Recommended)
// ✅ FIXED: WaitUntil confirms state, then Capture, then exit
var snapshot = await new Hex1bTerminalInputSequenceBuilder()
.Key(Hex1bKey.A)
.Key(Hex1bKey.B)
.WaitUntil(s => s.ContainsText("Counter: 3"), TimeSpan.FromSeconds(2))
.Capture("final")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyWithCaptureAsync(terminal, TestContext.Current.CancellationToken);
await runTask;
// If the WaitUntil passed, we know the content was there at Capture time
// The assertion is now checking what WaitUntil already verified
Assert.IsTrue(snapshot.ContainsText("Counter: 3"));
Option B: Don't use snapshot for content assertions
// ✅ ALTERNATIVE: Use render counters or other non-snapshot assertions
var runTask = app.RunAsync(TestContext.Current.CancellationToken);
await new Hex1bTerminalInputSequenceBuilder()
.Key(Hex1bKey.A)
.Key(Hex1bKey.B)
.Capture("final")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyWithCaptureAsync(terminal, TestContext.Current.CancellationToken);
await runTask;
// Assert on counters/state captured during execution, not snapshot content
Assert.AreEqual(1, staticRenderCount);
Option C: Use WaitUntil as the assertion itself
// ✅ ALTERNATIVE: WaitUntil IS the assertion - if it passes
Установить test-fixer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл test-fixer?
Agent for diagnosing and fixing flaky terminal UI tests in the Hex1b test suite. Use when tests pass locally but fail in CI, or when tests exhibit timing-sensitive behavior.
Как установить скилл test-fixer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл test-fixer запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic