Skip to main content

AI-Powered Test Flakiness Detection & Root Cause Analysis - Enterprise-grade analytics for test reliability

Project description

๐Ÿ” FlakeRadar

AI-Powered Test Flakiness Detection & Root Cause Analysis

Python 3.9+ MIT License Enterprise Ready AI Powered Statistical Analysis


๐ŸŽฏ What is FlakeRadar?

FlakeRadar is an intelligent test analysis platform that transforms raw test results into actionable insights. It combines statistical analysis, AI-powered root cause detection, and time-tracking analytics to help engineering teams eliminate flaky tests and improve CI/CD reliability.

"The GitHub Copilot for Test Quality" - Identify, prioritize, and fix unreliable tests with enterprise-grade analytics.

๐Ÿ”ฅ Key Problems Solved

Problem FlakeRadar Solution
๐Ÿšจ False Flaky Alerts Statistical confidence scoring (Wilson intervals)
โฑ๏ธ Unknown Fix Priority Time-to-fix tracking & productivity impact analysis
๐Ÿ” Manual Root Cause Analysis AI-powered pattern recognition & clustering
๐Ÿ“Š Lack of Metrics Enterprise dashboards with trend analysis
๐ŸŽฏ No Actionable Insights Specific recommendations per failure type

๐Ÿš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/your-repo/flakeradar.git
cd flakeradar

# Install dependencies
pip install -e .

# Optional: Enable AI analysis (requires OpenAI API key)
export OPENAI_API_KEY="your-api-key-here"

Basic Usage

# Analyze test results
flakeradar --project "MyApp" --results "test-results/*.xml"

# View beautiful HTML report
open flakeradar_report.html

Sample Output

๐Ÿšจ Worst Flaky Test Offenders (Time-to-Fix Analysis):
  ๐Ÿ“… DatabaseTest#connectionPool: 14 days flaky, 45 failures (Still Flaky)
  ๐Ÿ“… AuthTest#tokenRefresh: 7 days flaky, 23 failures (Still Flaky)

๐Ÿ” Root Cause Clustering Analysis:
  ๐Ÿ”ด database_connectivity: 15 failures, 8 tests affected
     ๐Ÿ’ก ๐Ÿ—„๏ธ Database: Check connection pool settings, network connectivity
  ๐ŸŸ  timing_race_conditions: 8 failures, 4 tests affected  
     ๐Ÿ’ก โฑ๏ธ Timing: Add proper waits, review async operations

๐Ÿค– Analyzing 12 failing tests with AI...
โœ… AI analysis complete

๐Ÿ“Š Enterprise Features

1. ๐ŸŽฏ Statistical Confidence Scoring

FlakeRadar uses advanced statistical analysis to eliminate false positives:

  • Wilson Score Intervals: Industry-standard confidence calculation (95% CI)
  • Transition Analysis: True flaky tests change states (passโ†’failโ†’pass)
  • Sample Size Considerations: Minimum thresholds prevent unreliable classifications
  • Confidence Threshold: Only tests with 70%+ confidence marked as flaky
# Example: High confidence flaky test
Test: UserLoginTest#validateCredentials
โ”œโ”€โ”€ Sample Size: 20 runs (100% confidence factor)
โ”œโ”€โ”€ Transitions: 8 state changes (84% confidence factor)  
โ”œโ”€โ”€ Wilson Score: Narrow interval around 40% (90% confidence)
โ””โ”€โ”€ Final Confidence: 76% โœ… (Marked as flaky)

2. โฑ๏ธ Time-to-Fix Analytics

Track productivity impact with sophisticated lifecycle monitoring:

  • Flaky Test Lifecycle: First detected โ†’ Duration flaky โ†’ Fixed timestamp
  • Worst Offenders: Tests consuming most engineering time
  • Team Metrics: Average resolution time, fix velocity trends
  • Cost Analysis: Engineering hours lost to debugging flaky tests
๐Ÿ“Š Time-to-Fix Insights:
โ”œโ”€โ”€ Average Resolution: 5.2 days
โ”œโ”€โ”€ Productivity Cost: 12 hours/week debugging
โ”œโ”€โ”€ Worst Offender: DatabaseTest (21 days flaky, $3,200 cost)
โ””โ”€โ”€ Trend: 40% improvement in resolution time this month

3. ๐Ÿง  AI-Powered Root Cause Analysis

Intelligent pattern recognition clusters failures by actual root causes:

๐Ÿ” Root Cause Categories:
โ”œโ”€โ”€ ๐Ÿ—„๏ธ Database Connectivity (connection, pool, timeout)
โ”œโ”€โ”€ ๐ŸŒ Network/API Issues (http, socket, unreachable)  
โ”œโ”€โ”€ โฑ๏ธ Timing/Race Conditions (async, thread, wait)
โ”œโ”€โ”€ ๐Ÿ’พ Resource Constraints (memory, disk, cpu)
โ”œโ”€โ”€ ๐Ÿ” Auth/Permission Issues (token, credential, forbidden)
โ”œโ”€โ”€ ๐Ÿ“Š Data/State Issues (null, missing, invalid)
โ””โ”€โ”€ โš™๏ธ Environment/Config (variables, settings, properties)

Smart Recommendations:

  • Fix one database issue โ†’ resolve 8 test failures
  • Targeted guidance per cluster type
  • Severity scoring based on impact scope

4. ๐Ÿ“ˆ Beautiful Analytics Dashboard

Professional HTML reports with interactive visualizations:

  • ๐Ÿ“Š Executive Summary: Key metrics, confidence scores, trend analysis
  • ๐Ÿ“ˆ Flakiness Trend Line: Visual representation sorted by severity
  • โฑ๏ธ Time-to-Fix Tables: Chronic issues requiring immediate attention
  • ๐Ÿ” Root Cause Matrix: Clustered failures with actionable recommendations
  • ๐ŸŽฏ Priority Indicators: Color-coded urgency levels

๐Ÿ”ง Advanced Configuration

Supported Test Frameworks

Framework Status File Formats
JUnit โœ… Supported *.xml
TestNG โœ… Supported *.xml
Pytest ๐Ÿšง Coming Soon junit.xml
Jest ๐Ÿšง Coming Soon *.xml

Configuration Options

# Full command options
flakeradar \
  --project "MyApp"                    # Project identifier
  --results "tests/**/*.xml"           # Test result glob pattern  
  --mode local                         # Analysis mode (local/push)
  --build "build-123"                  # CI build identifier
  --commit "abc123"                    # Git commit SHA
  --report-out "custom-report.html"    # Output file path

Environment Variables

# Enable AI-powered analysis (optional)
export OPENAI_API_KEY="sk-..."

# Custom database location
export FLAKERADAR_DB_PATH="/custom/path/flakeradar.db"

# Disable external API calls
unset OPENAI_API_KEY

๐Ÿ—๏ธ Architecture & Data Flow

graph LR
    A[Test Results] --> B[Parser Engine]
    B --> C[Statistical Analysis]
    C --> D[Flakiness Detection]
    D --> E[Root Cause Clustering]
    E --> F[AI Analysis]
    F --> G[Time Tracking]
    G --> H[Priority Scoring]
    H --> I[Beautiful Reports]
    
    J[SQLite Database] --> C
    K[OpenAI API] --> F
    L[Historical Data] --> G

Core Components

Component Purpose Technology
Parser Engine Multi-format test result parsing lxml, xml.etree
Statistical Engine Confidence scoring, Wilson intervals math, custom algorithms
AI Analysis Root cause suggestions OpenAI GPT-4o-mini
Database Layer Historical tracking, lifecycle management SQLite, time-series data
Report Engine Interactive dashboards Jinja2, Chart.js, modern CSS

๐Ÿ“Š Priority Decision Matrix

FlakeRadar uses multi-layered priority intelligence to help teams focus on high-impact fixes:

๐Ÿšฆ Visual Priority (Flake Rate)

  • ๐Ÿ”ด High: >50% flake rate (deployment blockers)
  • ๐ŸŸ  Medium: 20-50% flake rate (reliability concerns)
  • ๐ŸŸข Low: <20% flake rate (stable tests)

โฑ๏ธ Time-to-Fix Priority

  • ๐Ÿ”ด Critical: >7 days flaky (chronic productivity killers)
  • ๐ŸŸ  High: 3-7 days flaky (emerging issues)
  • ๐ŸŸข Medium: <3 days flaky (new problems)

๐Ÿ” Root Cause Severity

  • ๐Ÿ”ด Critical: 5+ tests affected, 10+ failures (infrastructure crisis)
  • ๐ŸŸ  High: 3+ tests affected, 5+ failures (significant pattern)
  • ๐ŸŸก Medium: 2+ tests affected OR 3+ failures (emerging pattern)

๐ŸŽฏ Use Cases & ROI

For Engineering Managers

๐Ÿ“ˆ Metrics Dashboard:
โ”œโ”€โ”€ Test reliability improved 75%
โ”œโ”€โ”€ CI/CD failure rate reduced 60% 
โ”œโ”€โ”€ Engineering time saved: 15 hours/week
โ””โ”€โ”€ Mean time to resolution: 3.2 days โ†’ 1.8 days

For QA Engineers

๐Ÿ” Smart Analysis:
โ”œโ”€โ”€ AI-powered failure categorization
โ”œโ”€โ”€ Statistical confidence prevents false alerts
โ”œโ”€โ”€ Actionable recommendations per failure type
โ””โ”€โ”€ Historical trend analysis for pattern recognition

For DevOps Teams

๐Ÿ—๏ธ Infrastructure Insights:
โ”œโ”€โ”€ Database connectivity issues affecting 8 tests
โ”œโ”€โ”€ Network timeout patterns in staging environment
โ”œโ”€โ”€ Resource constraint analysis (memory, CPU, disk)
โ””โ”€โ”€ Environment configuration drift detection

๐Ÿš€ CI/CD Integration

GitHub Actions

name: FlakeRadar Analysis
on: [push, pull_request]

jobs:
  flake-analysis:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Run Tests
        run: mvn test
      - name: Analyze Flakiness
        run: |
          pip install flakeradar
          flakeradar --project "${{ github.repository }}" \
                    --results "target/surefire-reports/*.xml" \
                    --build "${{ github.run_number }}" \
                    --commit "${{ github.sha }}"
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
      - name: Upload Report
        uses: actions/upload-artifact@v3
        with:
          name: flakeradar-report
          path: flakeradar_report.html

Jenkins Pipeline

pipeline {
    agent any
    stages {
        stage('Test Analysis') {
            steps {
                sh 'mvn test'
                sh '''
                    pip install flakeradar
                    flakeradar --project "${JOB_NAME}" \
                              --results "target/surefire-reports/*.xml" \
                              --build "${BUILD_NUMBER}" \
                              --commit "${GIT_COMMIT}"
                '''
                publishHTML([
                    allowMissing: false,
                    alwaysLinkToLastBuild: true,
                    keepAll: true,
                    reportDir: '.',
                    reportFiles: 'flakeradar_report.html',
                    reportName: 'FlakeRadar Report'
                ])
            }
        }
    }
}

๐Ÿ“š API Reference

Command Line Interface

flakeradar [OPTIONS]

Options:
  --project TEXT       Project name identifier [required]
  --results TEXT       Glob pattern for test result files [required]  
  --logs TEXT          Glob pattern for log files (future feature)
  --mode TEXT          Analysis mode: local|push [default: local]
  --build TEXT         CI build identifier [default: local-build]
  --commit TEXT        Git commit SHA [default: local]
  --report-out TEXT    HTML report output path [default: flakeradar_report.html]
  --help               Show this message and exit

Python API

from flakeradar import FlakeRadar

# Initialize analyzer
radar = FlakeRadar(project="MyApp")

# Add test results
radar.add_results("test-results/*.xml")

# Analyze flakiness
analysis = radar.analyze(
    confidence_threshold=0.7,
    enable_ai=True,
    track_time_to_fix=True
)

# Generate reports
radar.generate_html_report("report.html")
radar.export_metrics("metrics.json")

๐Ÿ”’ Security & Privacy

Data Handling

  • Local Storage: All analysis data stored locally in SQLite database
  • Optional AI: OpenAI integration requires explicit API key configuration
  • No Data Upload: Test results never leave your infrastructure (local mode)
  • Audit Trail: All API calls logged with timestamps and error details

API Usage Transparency

๐Ÿค– AI Analysis Status:
โ”œโ”€โ”€ API Calls Made: 5
โ”œโ”€โ”€ Tests Analyzed: 12 failing tests  
โ”œโ”€โ”€ Tokens Used: ~1,200 (estimated cost: $0.03)
โ”œโ”€โ”€ Success Rate: 100%
โ””โ”€โ”€ Privacy: Error messages sanitized, no source code sent

๐Ÿค Contributing

We welcome contributions! FlakeRadar is designed to be extensible and enterprise-ready.

Development Setup

# Clone repository
git clone https://github.com/your-repo/flakeradar.git
cd flakeradar

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest tests/

# Run with sample data
flakeradar --project "FlakeRadar" --results "src/flakeradar/sample_results/*.xml"

Architecture Extensibility

# Add new test result parsers
class CustomParser(BaseParser):
    def parse(self, file_path: str) -> List[TestCaseResult]:
        # Custom parsing logic
        pass

# Add new root cause patterns  
class CustomClusterAnalyzer(BaseClusterAnalyzer):
    def extract_signature(self, result: TestCaseResult) -> str:
        # Custom pattern matching
        pass

# Add new AI providers
class CustomAIProvider(BaseAIProvider):
    def analyze_failure(self, error_details: str) -> str:
        # Custom AI analysis
        pass

Roadmap

  • Pytest Support: Native pytest result parsing
  • Jest Integration: JavaScript test framework support
  • Slack/Teams Integration: Real-time flaky test notifications
  • JIRA Integration: Automatic ticket creation for chronic issues
  • GitHub PR Comments: Flake risk assessment before merge
  • PostgreSQL Backend: Enterprise-scale data storage
  • REST API: Programmatic access to all features
  • Docker Images: Containerized deployment options

License

FlakeRadar is licensed under the MIT License. See LICENSE for full details.


Ready to eliminate flaky tests?

๐Ÿš€ Get Started Now


Built with โค๏ธ by engineers who understand the pain of flaky tests

FlakeRadar - The AI-Powered Test Intelligence Platform

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flakeradar-1.0.3.tar.gz (39.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flakeradar-1.0.3-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file flakeradar-1.0.3.tar.gz.

File metadata

  • Download URL: flakeradar-1.0.3.tar.gz
  • Upload date:
  • Size: 39.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for flakeradar-1.0.3.tar.gz
Algorithm Hash digest
SHA256 6ae16543c149e6949dd34b3eb579f21596433db866f85722c0759973d7594a27
MD5 7eaf92d6c0c53c72165ba16301c13ba5
BLAKE2b-256 e5796b7aa9f7a9f8f1e60554b6b6456d69b88d14d7b85ff9c5d024ff9aab1fe6

See more details on using hashes here.

File details

Details for the file flakeradar-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: flakeradar-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for flakeradar-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9172a51572f9b4986d6119e01768e4e20ffda6d1cc7dcedfdfb226ee155e8896
MD5 c169c1874ebef1b8a66c17671392aa16
BLAKE2b-256 54e8b82c83e095e18e90b423e9dbf658cbc388d438646701270a32d7b40a8c2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page