Skip to main content

Allure Report Summarizer

A Python utility for analyzing and summarizing Allure test reports. This tool extracts detailed test execution statistics, timing information, and test status data from Allure HTML reports, providing comprehensive insights into test suite performance.

Features

  • Test Execution Statistics: Extracts total, passed, failed, broken, skipped, and unknown test counts
  • Timing Analysis: Provides start time, stop time, and duration of test executions
  • Pass Rate Calculation: Automatically calculates test suite pass rates
  • Unique Test Tracking: Identifies and counts unique test cases by status
  • JSON Export: Saves failed and passed test IDs to separate JSON files for further analysis
  • Multiple Output Formats: Supports both console output and file-based summaries
  • Robust File Handling: Handles various file encodings (UTF-8, Latin1, CP1252, ISO-8859-1)
  • Environment Configuration: Configurable via environment variables

Installation

Requirements

  • Python 3.6+
  • Allure HTML report files

Install from PyPI

pip install allure-report-analyzer

Set environment variables

# Set the path for JSON output files (default: c:\reports\json_files)
export JSON_FILE_PATH="path/to/your/json/output"

# Set the Allure report directory path
export ALLURE_REPORT_PATH="path/to/allure/reports"

Usage

Command Line Usage

The CLI supports three main workflows:

  1. Summarize a report from ALLURE_REPORT_PATH
  2. Parse all matching Allure HTML reports in a directory with --all
  3. Print runtime analytics from a generated JSON file with --stats

Example commands:

# Use the report directory from the environment variable
export ALLURE_REPORT_PATH="/path/to/allure/reports"
allure-analyzer

# Save failed test IDs
allure-analyzer --fail

# Save passed test IDs
allure-analyzer --pass

# Parse all Allure HTML files under the report directory
allure-analyzer --all

# Load runtime statistics from a JSON file
allure-analyzer --stats path/to/test_runtime_data.json

You can also pass a report directory as the first positional argument. When present, the script first checks ALLURE_REPORT_PATH; if that location is not available, it falls back to the supplied path.

The script rejects common typoed flags:

-all    # use --all
-stat   # use --stats
--stat  # use --stats

Default execution does the following:

  1. Resolves the report directory from ALLURE_REPORT_PATH or the first positional argument
  2. Summarizes the report when running in single-report mode
  3. Generates aggregated runtime data
  4. Removes duplicate test IDs while keeping the most recent execution

Python API Usage

from report_summarize import summarize_html_report, save_summary_to_file, get_unique_test_count

# Summarize a report
summary = summarize_html_report("path/to/report.html")
print(summary)

# Output:
# {
#     'start_time': '2024-03-01 10:00:00',
#     'stop_time': '2024-03-01 11:00:00',
#     'duration': '1 hours 0 minutes 0 seconds',
#     'total': 100,
#     'passed': 90,
#     'failed': 10,
#     'broken': 0,
#     'skipped': 0,
#     'unknown': 0,
#     'pass_rate': '90.00%'
# }

# Save summary to file
save_summary_to_file(summary, "report_summary.txt")

# Get detailed test statistics
test_stats = get_unique_test_count("path/to/report.html")
print(f"Failed tests: {len(test_stats['failed'])}")
print(f"Passed tests: {len(test_stats['passed'])}")

Advanced Usage

from report_summarize import (
    get_report_path,
    get_summary_message,
    get_file_size_in_mb,
    read_html_file,
    extract_test_data
)

# Get the latest report file path
report_path = get_report_path("/path/to/reports")

# Read HTML content with encoding handling
content = read_html_file(report_path)

# Extract test data
test_data = extract_test_data(content)

# Get file size
size = get_file_size_in_mb(report_path)
print(f"Report size: {size}")

# Generate formatted message
summary = summarize_html_report(report_path)
message = get_summary_message(summary)
print(message)

Configuration

Environment Variables

Variable Description Default
ALLURE_REPORT_PATH Directory containing Allure HTML reports Required (no default)
JSON_FILE_PATH Directory for JSON output files c:\reports\json_files

Output Files

The script can generate the following files in the JSON_FILE_PATH directory:

  • failed_testscripts.json: List of failed test case IDs when --fail is used
  • passed_testscripts.json: List of passed test case IDs when --pass is used
  • test_runtime_data.json: Deduplicated runtime data used for runtime analysis

Temporary files created during aggregation are cleaned up automatically:

  • processed_data.json
  • test_execution.json

API Reference

Core Functions

summarize_html_report(report_path: str) -> Dict[str, Any]

Summarizes an Allure HTML report and returns statistics.

Parameters:

  • report_path: Path to the Allure HTML report file

Returns:

  • Dictionary with test execution statistics

get_unique_test_count(html_file_path: str) -> Dict[str, List[str]]

Analyzes test results and returns unique test counts by status.

Parameters:

  • html_file_path: Path to the HTML report file

Returns:

  • Dictionary with lists of test IDs by status

save_summary_to_file(summary: Dict[str, Any], file_path: str)

Saves summary data to a text file.

get_report_path(attachment_path: str) -> str

Gets the path to the latest report file in a directory.

Utility Functions

get_filename(directory: str) -> str

Gets the first HTML file found in a directory.

read_html_file(html_file: str) -> Optional[str]

Reads an HTML file with multiple encoding fallbacks.

extract_test_data(html_content: str) -> Optional[Dict]

Extracts test data from embedded JSON in HTML content.

get_file_size_in_mb(file_path: str) -> str

Returns file size in megabytes.

Error Handling

The module includes comprehensive error handling for:

  • File not found errors
  • Invalid JSON data
  • Encoding issues
  • Missing data fields
  • Directory access problems

All errors are logged to console with descriptive messages.

CLI Options

After installation, use the allure-analyzer command:

Option Description
--all Parse all Allure HTML reports found under the resolved report directory
--stats <json_file_path> Load and print runtime statistics from an existing JSON file
--fail Export failed test IDs to failed_testscripts.json
--pass Export passed test IDs to passed_testscripts.json
--version Show version information

Examples

Basic Report Analysis

from report_summarize import summarize_html_report

# Analyze a single report
summary = summarize_html_report("allure-report/index.html")
for key, value in summary.items():
    print(f"{key}: {value}")

Batch Processing Multiple Reports

import os
from report_summarize import summarize_html_report

reports_dir = "/path/to/reports"
for filename in os.listdir(reports_dir):
    if filename.endswith('.html'):
        report_path = os.path.join(reports_dir, filename)
        summary = summarize_html_report(report_path)
        print(f"Report: {filename}")
        print(f"Pass Rate: {summary['pass_rate']}")

Runtime Statistics From JSON

python allure_report_summarizer/report_summarize.py --stats path/to/test_runtime_data.json

This command prints:

  • overall pass, fail, and broken counts
  • total and average runtime
  • slowest tests
  • tests with high scenario counts
  • execution statistics grouped by report file

Custom Output Formatting

from report_summarize import summarize_html_report, get_unique_test_count

report_path = "allure-report/index.html"
summary = summarize_html_report(report_path)
test_stats = get_unique_test_count(report_path)

print("=== TEST EXECUTION SUMMARY ===")
print(f"Duration: {summary['duration']}")
print(f"Total Tests: {len(test_stats['total'])}")
print(f"Passed: {len(test_stats['passed'])}")
print(f"Failed: {len(test_stats['failed'])}")
print(f"Pass Rate: {summary['pass_rate']}")

if test_stats['failed']:
    print("\nFailed Test IDs:")
    for test_id in test_stats['failed'][:10]:  # Show first 10
        print(f"  - {test_id}")
    if len(test_stats['failed']) > 10:
        print(f"  ... and {len(test_stats['failed']) - 10} more")

Dependencies

  • Python 3.6+
  • Standard library modules: json, os, re, datetime, typing

License

MIT License

Metadata

Release files for allure-report-analyzer 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for allure-report-analyzer 1.0.6
File Size Uploaded Provenance
allure_report_analyzer-1.0.6.tar.gz 19.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for allure-report-analyzer 1.0.6
File Interpreter ABI Platform
allure_report_analyzer-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 37.3 kB

Release files / allure_report_analyzer-1.0.6.tar.gz

Download URL allure_report_analyzer-1.0.6.tar.gz
Size 19.3 kB
Tags Source
SHA-256 checksum
How to use checksums
73e26319213e4375d61e9f5035c623350de9db3861eac62c6ae745c43e9fb244
BLAKE2b-256 checksum
How to use checksums
b1b22cdbdacf28b643eb68f0e21b82badb8529c481a064fd722a4d0bbb3d063d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / allure_report_analyzer-1.0.6-py3-none-any.whl

Download URL allure_report_analyzer-1.0.6-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fb556a16adf22e87eec40adf82aa09e4b6dd6720f831fac19da6788eaa5e2a5
BLAKE2b-256 checksum
How to use checksums
4d5a9f4b6ce5660868efe34e700c934eeee8a773f9e3cea9ddd0d56bea32f7a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for allure-report-analyzer 1.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page