Skip to main content

Interactive RCA report generator for pytest runs, with AI-based analysis and visual dashboard

Project description

RCA Report Generator

A modern, interactive reporting dashboard for Pytest-based QA automation projects.
Generates a clear Root Cause Analysis (RCA) report, supporting rapid investigation, team triage, and continuous improvement.

Features

  • Visual summary of all test results (pass/fail/skip), anomalies, and execution times.
  • Root Cause Analysis: Highlights failing modules/scripts.
  • Interactive test table with search, status filtering, and drilldown for each test case.
  • Classification of failures: Distinguishes between likely real bugs and probable test/infrastructure issues.
  • Actionable recommendations generated by LLM (e.g. GPT-4).
  • Downloadable results in JSON/CSV.
  • Summary graphs (pie/bar) and execution time distribution.
  • Responsive UI – optimized for both desktop and mobile.
  • Works with any Pytest project: Supports unit, integration, and end-to-end tests, as long as JUnit XML is generated.

Demo

RCA Dashboard Demo

Quick Start

You can also install via pip if available:

pip install pytest-rca-report

1. Download and Set Up

  1. Clone or download this repository:

    git clone https://github.com/keinar/pytest-rca-report.git
    

    Or download as ZIP and extract.

  2. (Optional) Move or symlink the folder into your automation project repo.

    You can keep this tool anywhere, but for convenience, place it inside or next to your main automation repo.

  3. Install dependencies:

    cd pytest-rca-report
    pip install -r requirements.txt
    

2. Generate pytest results and log

After running your test suite, make sure to have:

  • pytest-results.xml (Pytest JUnit XML output)
  • automation.log (optional, for enhanced RCA)

Example:

pytest --junitxml=pytest-results.xml

3. Run the RCA generator

Navigate to the pytest-rca-report directory and run:

python parser.py
  • Requires Python 3.9+ and OpenAI API key set as OPENAI_API_KEY in your environment.
  • The script will automatically create the data/ folder if it doesn't exist, and will generate data/results.json.
  • At the end of the run, the interactive dashboard will be generated in the ./dashboard folder.
  • Due to browser security (CORS) restrictions, you should view the dashboard using a local web server.
    To view the dashboard with full data, run:
    python -m http.server 8000 --directory dashboard
    
    Then open:
    http://localhost:8000/index.html
    
  • On most systems, the dashboard will also open automatically after the script completes.

Compatibility:
The RCA Report Generator works with any Pytest project that produces a JUnit XML file – from unit tests to full end-to-end suites.


Configuration

The main script (parser.py) uses the following paths and model by default:

XML_PATH = './pytest-results.xml'
LOG_PATH = './automation.log'
OUT_JSON = './data/results.json'
MODEL = 'gpt-4o-mini'
  • If your files are located elsewhere, or you wish to change the output location or LLM model, edit these variables at the top of parser.py.

  • Supported OpenAI models: you can specify any available chat/completions model (e.g., gpt-4o-mini, gpt-4-turbo).


Folder Structure

pytest-rca-report/
├── src/
│   └── rca_report/
│       ├── __init__.py
│       ├── parser.py
│       ├── assets/
│       │   ├── index.html
│       │   └── static/
│       │       ├── css/
│       │       │   └── style.css
│       │       └── js/
│       │           └── app.js
├── data/
│   └── results.json        # Processed summary/report file (generated)
├── dashboard/              # Generated interactive dashboard (after running parser.py)
│   └── index.html
│   └── static/
├── pytest-results.xml      # Input: JUnit XML from Pytest
├── automation.log          # Input: test logs (optional)
├── pyproject.toml
├── README.md
├── LICENSE
├── .env.example
├── .gitignore

Note: When installed via pip, you can run the CLI from any directory. All assets are included in the package under src/rca_report/assets/.


Usage & Navigation

  • Results Summary: Top summary of all tests.
  • Summary Graphs: Pie & bar charts of pass/fail/skip.
  • Log Anomalies: Aggregated errors and warnings across all tests.
  • Root Cause Analysis: Failure counts per module/script.
  • Execution Time: Histogram & slowest tests listed.
  • Actionable Recommendations: Next steps as suggested by the LLM.
  • All Testcases Table:
    • Search any test by name.
    • Filter by status (Passed/Failed/Skipped).
    • Click any row for a detailed modal with properties and failure reason.
    • Download all results as JSON or CSV.
  • Failure Classification: Clear separation between likely real bugs and possible test automation issues.

Customization

  • To further enhance analysis, you can add more record_property info in your Pytest tests (these appear as custom properties in the report).
  • All frontend code (JS/CSS/HTML) is modular and can be extended as needed.

Requirements

  • Python 3.9+
  • OpenAI Python SDK
  • Internet access for LLM processing
  • A modern browser (Chrome, Firefox, Edge, Safari)

You can install dependencies either by cloning the repo and running:

pip install -r requirements.txt

or by installing the package from PyPI (if available):

pip install pytest-rca-report

Troubleshooting

  • results.json not found? Run parser.py after you have a fresh pytest-results.xml.
  • Chart not showing? Ensure you have execution time data in the XML.
  • CORS issues / Dashboard not loading data?
    Due to browser security restrictions, opening index.html directly via file:// will not load data properly.
    Instead, serve the dashboard folder with a local web server:
    python -m http.server 8000 --directory dashboard
    
    Then open in your browser:
    http://localhost:8000/index.html
    
  • LLM recommendations irrelevant? Refine the prompt in parser.py.

Roadmap / Suggestions

  • Regression trend analysis between runs
  • "Mark as Known Issue" UI
  • Integration with defect tracking (Jira etc.)
  • Team comments on test failures

License

MIT License

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

pytest_rca_report-0.1.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

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

pytest_rca_report-0.1.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest_rca_report-0.1.0.tar.gz.

File metadata

  • Download URL: pytest_rca_report-0.1.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pytest_rca_report-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f9f5d47232629edb900496ce90e016fdcd6709dcda6aa155500e23231fad6059
MD5 28b53475b95f885ec5bb2810f16d2666
BLAKE2b-256 b56c287fd89070b2e9e0c141fdf5ccc2cfdec9b90cccb72c3612e39ec4a418b1

See more details on using hashes here.

File details

Details for the file pytest_rca_report-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_rca_report-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6100fb5a3462d2c0cc7050d4fc4f7aaffecd5434b87ab9dc040ba7c0b2dbcd91
MD5 204e09edeb956429e6a008394ff2c6fb
BLAKE2b-256 d6b62d716c52d71b86d2a1c2beb5e644caaf994e7946b811a851ee7883279a02

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