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.1.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.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_rca_report-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 13cf8fd5448dca3deced8e5272a333c5293f539d1b4f71b8ee3ae1797eddf68c
MD5 888452613284ac11cf6cd0d8c43d00ef
BLAKE2b-256 bef81fe426171ddbc876b407d32e9b0a03d50e944ab9134a219d7627488ac245

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_rca_report-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6cbfab74f7ae422328694140188119465be89a8a95fa6dc931bbf32cbac8fe72
MD5 b36fcb208c139fca99081dcf4d6e2c07
BLAKE2b-256 4cf9c6775206b1d677fa09610002334745c6eb1147fff1c73e6dc57a071e194a

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