Logo di Flaky Test Detector

Flaky Test Detector

Community
ArabelaTso
flaky-test-detector

Identifies non-deterministic or unreliable tests through static code analysis and test result analysis. Use when Claude needs to find flaky tests, analyze test reliability, or investigate intermittent test failures. Supports Python (pytest, unittest) and Java (JUnit, TestNG) test frameworks. Trigger when users mention "flaky tests", "intermittent failures", "non-deterministic tests", "unreliable tests", or ask to "find flaky tests", "analyze test stability", or "why tests fail randomly".

Panoramica

AutoreArabelaTso
RepositorySkills-4-SE
Nome della skillflaky-test-detector
Stelle
258
Fork
25
File inclusi
3
LicenzaApache-2.0
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • 3 file inclusi

    Script, modelli di documento e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da ArabelaTso su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Flaky Test Detector in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/flaky-test-detector
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE.git /tmp/Skills-4-SE
mkdir -p .claude/skills
cp -r /tmp/Skills-4-SE/skills/flaky-test-detector .claude/skills/flaky-test-detector
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Flaky Test Detector in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Flaky Test Detector non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Flaky Test Detector non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Flaky Test Detector

Identify and fix non-deterministic tests that intermittently fail without code changes.

Quick Start

When a user reports flaky tests or asks for test reliability analysis:

  1. Identify the approach: Determine if analyzing code patterns or test execution results
  2. Analyze for flakiness: Look for common flaky patterns in test code or execution history
  3. Report findings: List identified flaky tests with specific issues
  4. Suggest fixes: Provide concrete remediation strategies

What Makes Tests Flaky

Flaky tests fail intermittently without code changes due to:

  • Timing issues: Race conditions, fixed sleeps, async/await problems
  • State management: Shared state between tests, improper cleanup
  • External dependencies: Network calls, database connections, file system
  • Randomness: Unseeded random data, UUID generation
  • Time dependencies: Current time/date, timezone assumptions
  • Resource issues: Leaks, insufficient cleanup
  • Test order: Dependencies between tests
  • Environment: Hardcoded paths, missing env vars

Detection Methods

Static Code Analysis

Analyze test code for common flaky patterns.

When to use:

  • Reviewing test code for potential issues
  • Proactive flakiness prevention
  • Code review of new tests
  • Refactoring existing tests

Process:

  1. Read test files
  2. Search for flaky patterns (see flaky-patterns.md)
  3. Identify specific issues with line numbers
  4. Suggest fixes (see remediation-strategies.md)

Common patterns to detect:

Timing issues:

  • time.sleep(), Thread.sleep() - Fixed waits
  • Missing await in async functions
  • Race conditions with threading

State issues:

  • Class or global variables in test classes
  • Missing setUp/tearDown or fixtures
  • Database operations without cleanup

External dependencies:

  • requests.get(), http.client - Real network calls
  • Database connections to production/external DBs
  • File operations without temp directories

Randomness:

  • random. without seed
  • UUID.randomUUID() without mocking
  • Non-deterministic data generation

Time dependencies:

  • datetime.now(), System.currentTimeMillis()
  • Timezone-dependent assertions
  • Date comparisons without mocking

Test Result Analysis

Analyze test execution history to find inconsistent results.

When to use:

  • Tests are failing intermittently in CI/CD
  • Investigating specific test reliability
  • Analyzing test suite health
  • Tracking flakiness over time

Process:

  1. Collect test results from multiple runs
  2. Use scripts/analyze_test_results.py to analyze patterns
  3. Review flakiness scores and patterns
  4. Investigate high-scoring tests

Script usage:

bash
python scripts/analyze_test_results.py test_results.json

Input format (JSON):

json
[
  {
    "test_name": "test_user_login",
    "status": "passed",
    "timestamp": "2024-01-01T10:00:00",
    "duration": 1.23
  },
  {
    "test_name": "test_user_login",
    "status": "failed",
    "timestamp": "2024-01-01T11:00:00",
    "duration": 1.45
  }
]

Metrics:

  • Flakiness score: 0-1, higher = more flaky (based on pass rate variance)
  • Pass rate: Percentage of successful runs
  • Pattern: Recent pass/fail sequence (P = pass, F = fail)
  • Alternating: Whether test alternates between pass/fail
  • Duration variance: Inconsistent execution time indicates issues

Framework-Specific Guidance

Python (pytest, unittest)

Common issues:

  • Missing fixtures or improper fixture scope
  • Shared class variables
  • Not using tmp_path for file operations
  • Missing @pytest.mark.django_db for database tests
  • Unseeded random module usage

Best practices:

  • Use fixtures for test data and cleanup
  • Use tmp_path fixture for file operations
  • Mock external calls with pytest-mock or unittest.mock
  • Use freezegun for time mocking
  • Seed random with random.seed()

Java (JUnit, TestNG)

Common issues:

  • Static variables in test classes
  • Missing @Before/@After cleanup
  • Not using @Transactional for database tests
  • Fixed Thread.sleep() calls
  • Hardcoded file paths

Best practices:

  • Use @Before/@After for setup/cleanup
  • Use @Transactional for automatic rollback
  • Mock with Mockito
  • Use Clock for time mocking
  • Use try-with-resources for resource management

Workflow

1. Understand the Context

Ask clarifying questions:

  • What tests are flaky?
  • How often do they fail?
  • What's the failure pattern?
  • Any recent changes?
  • CI/CD or local environment?

2. Choose Detection Method

Static analysis if:

  • Reviewing code proactively
  • No test execution history available
  • Want to prevent flakiness

Result analysis if:

  • Have test execution history
  • Tests failing intermittently
  • Need to quantify flakiness

3. Analyze for Flakiness

For static analysis:

  • Read test files
  • Search for patterns from flaky-patterns.md
  • Note specific issues with line numbers
  • Categorize by issue type

For result analysis:

  • Run analyze_test_results.py script
  • Review flakiness scores
  • Identify high-risk tests
  • Examine failure patterns

4. Report Findings

Structure the report:

  • Summary: Number of flaky tests found
  • High priority: Tests with highest flakiness scores
  • By category: Group by issue type
  • Specific issues: File paths and line numbers

Example format:

Found 5 potentially flaky tests:

HIGH PRIORITY:
- test_user_login (flakiness: 0.85)
  - Line 45: time.sleep(2) - fixed wait
  - Line 52: Shared class variable 'user_data'

MEDIUM PRIORITY:
- test_api_call (flakiness: 0.62)
  - Line 23: requests.get() - unmocked network call

5. Suggest Remediation

For each issue, provide:

  • What's wrong: Explain the flaky pattern
  • Why it's flaky: Describe the non-determinism
  • How to fix: Concrete code example

Reference remediation-strategies.md for detailed fixes.

Example Usage Patterns

User: "Our test_checkout test keeps failing randomly" → Analyze test code for flaky patterns, report findings with fixes

User: "Find all flaky tests in the test suite" → Scan all test files for common flaky patterns

User: "This test has a 60% pass rate, why?" → Analyze test code and suggest specific fixes

User: "Analyze these test results for flakiness" → Use analyze_test_results.py script on provided data

User: "How do I fix this race condition in my test?" → Provide remediation strategy with code examples

User: "Review this test for potential flakiness" → Static analysis of specific test with recommendations

Best Practices

Detection

  • Look for multiple flaky patterns, not just one
  • Consider the test framework's idioms
  • Check both test code and test fixtures/setup
  • Review recent changes that might introduce flakiness

Reporting

  • Prioritize by severity and frequency
  • Provide specific line numbers
  • Group related issues together
  • Include confidence level in assessment

Remediation

  • Suggest framework-appropriate fixes
  • Provide complete code examples
  • Explain why the fix works
  • Consider test maintainability

Prevention

  • Recommend test design patterns
  • Suggest CI/CD improvements (retry policies, test isolation)
  • Encourage test independence
  • Promote proper mocking and fixtures

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Flaky Test Detector?

Identifies non-deterministic or unreliable tests through static code analysis and test result analysis. Use when Claude needs to find flaky tests, analyze test reliability, or investigate intermittent test failures. Supports Python (pytest, unittest) and Java (JUnit, TestNG) test frameworks. Trigger when users mention "flaky tests", "intermittent failures", "non-deterministic tests", "unreliable tests", or ask to "find flaky tests", "analyze test stability", or "why tests fail randomly".

Perché usare Flaky Test Detector su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Flaky Test Detector è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Flaky Test Detector in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/flaky-test-detector. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Flaky Test Detector?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Flaky Test Detector?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Flaky Test Detector: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Flaky Test Detector è gratuita?

Sì. È pubblicata su GitHub da ArabelaTso con licenza Apache-2.0. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇