Skip to main content

Complete automation testing starter kit with pytest plugin, HTML reports, charts, and parallel execution support

Project description

Robo Automation Test Kit

A comprehensive pytest plugin for test automation reporting with interactive HTML reports, chart visualizations, and support for parallel test execution.

Python License PyPI

Features

  • ๐Ÿงช Pytest Plugin Integration - Seamless pytest hook-based integration
  • ๐Ÿ“Š Interactive HTML Reports - Beautiful, interactive test reports with charts
  • ๐Ÿ“ˆ Data Visualization - Multiple chart types:
    • Test status summary charts
    • Category breakdown analysis
    • Phase analysis
    • Center-based metrics
    • Status distribution by center
  • ๐Ÿ”„ Parallel Execution Support - Built-in support for pytest-xdist
  • ๐Ÿ“‘ CSV/Excel Data Parametrization - Load test data from CSV and Excel files
  • ๐ŸŽจ Customizable Reports - Extend reports with custom attributes and metrics
  • ๐Ÿš€ Zero Configuration - Works out of the box with sensible defaults

Installation

Basic Installation

pip install robo-automation-test-kit

With Optional Features

# For parallel test execution
pip install robo-automation-test-kit[parallel]

# For Selenium-based browser automation
pip install robo-automation-test-kit[selenium]

# For system utilities
pip install robo-automation-test-kit[utils]

# For development
pip install robo-automation-test-kit[pytest]

# All features combined
pip install robo-automation-test-kit[pytest,selenium,parallel,utils]

Using Poetry

poetry add robo-automation-test-kit

Quick Start

1. Basic Test Setup

Create a test file tests/test_example.py:

import pytest

class TestExample:
    def test_login_success(self):
        """User successfully logs in with valid credentials"""
        assert True
    
    def test_dashboard_loads(self):
        """Dashboard page loads and displays correctly"""
        assert True
    
    @pytest.mark.skip(reason="Feature not implemented")
    def test_future_feature(self):
        """This feature is planned for next release"""
        pass

2. Run Tests

# Run with default settings (parallel execution enabled by default)
pytest

# Run serially (disable parallel execution)
pytest -n 1

# Run specific test file
pytest tests/test_example.py::TestExample::test_login_success

3. View Report

After tests complete, open the generated HTML report:

reports/test_report_<timestamp>.html

4. Parameterized Tests with CSV Data

Create test data file data/TestData.csv:

username,password,expected_result
user1@example.com,ValidPass123,success
user2@example.com,WrongPass,failure
user3@example.com,ValidPass456,success

Create test with parametrization tests/test_login.py:

import pytest

class TestLogin:
    @pytest.mark.datafile("TestData.csv")
    def test_login_with_data(self, row):
        """Login test with parameterized data: {username}"""
        username = row['username']
        password = row['password']
        expected = row['expected_result']
        
        # Your test logic here
        result = login(username, password)
        assert result == expected

Configuration

pytest.ini

Basic configuration is pre-configured in pytest.ini:

[pytest]
addopts = -n logical --capture=tee-sys
markers = 
    datafile: Mark test to use CSV/Excel data parametrization

Environment Variables

Control test behavior via environment variables:

# Windows PowerShell
$env:LOG_LEVEL="DEBUG"
$env:PARALLEL_EXECUTION="N"  # Disable parallel execution
$env:PROJECT_NAME="My Project"
$env:APP_ENV="staging"
$env:TEST_FRAMEWORK="pytest"
$env:REPORT_PATH="reports"  # Report output folder (relative to project root)
$env:DATA_FILES_PATH="data"  # Data files base folder (relative to project root)
$env:DATA_FILES_PATH="C:/path/to/data"  # Base folder containing env subfolders (e.g., uat, dev)

# Run tests
pytest
# Linux/macOS
export LOG_LEVEL=DEBUG
export PARALLEL_EXECUTION=N
export PROJECT_NAME="My Project"
export REPORT_PATH="reports"  # Report output folder (relative to project root)
export DATA_FILES_PATH="data"  # Data files base folder (relative to project root)
export DATA_FILES_PATH="/path/to/data"  # Base folder containing env subfolders (e.g., uat, dev)

pytest

Dynamic Logging

Control pytest log level at runtime:

# Windows PowerShell
$env:LOG_LEVEL="WARNING"
pytest --log-cli-level=$env:LOG_LEVEL
# Linux/macOS
export LOG_LEVEL=WARNING
pytest --log-cli-level=$LOG_LEVEL

Valid log levels: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET

Report Path Resolution

REPORT_PATH accepts:

  • Relative paths (e.g., reports) resolved from the project root.
  • Absolute paths (e.g., C:/reports or /var/reports).

On Windows, a leading-slash path like /reports is treated as project-root relative to avoid writing to the drive root (e.g., C:\reports).

Data Files Path Resolution

DATA_FILES_PATH points to the base folder that contains your data files used by @pytest.mark.datafile(...).

Examples:

  • data โ†’ resolves to <project_root>/data
  • C:/my-data โ†’ uses an absolute path

On Windows, a leading-slash path like /data is treated as project-root relative to avoid resolving to C:\data.

Advanced Usage

Customize Report Titles

pytest --robo-report-title="Smoke Tests - Sprint 45"

Custom Report Attributes

Extend conftest.py with the robo_modify_report_row hook:

def robo_modify_report_row(report_row, test_data):
    """Add custom attributes to each test result"""
    report_row['phase'] = test_data.get('Phase', 'General')
    report_row['category'] = test_data.get('Request Category', 'Functional')
    report_row['center'] = test_data.get('Center', 'HQ')

Disable Parallel Execution Conditionally

# Via environment variable
export PARALLEL_EXECUTION=N
pytest

# Via command line
pytest -n 1

Report Structure

Generated HTML reports include:

  • Summary Dashboard - Quick overview of test results
  • Status Charts - Visual breakdown of PASSED/FAILED/SKIPPED tests
  • Category Analysis - Test distribution by category
  • Phase Breakdown - Test distribution by phase
  • Results Table - Detailed results with test names, duration, status, and logs
  • Error Details - Full error messages and stack traces for failed tests

Architecture

robo_automation_test_kit/
โ”œโ”€โ”€ plugin.py                 # Pytest hook implementations
โ”œโ”€โ”€ hookspec.py              # Hook specifications
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ RoboHelper.py        # Core utilities (CSV loading, result aggregation)
โ”‚   โ””โ”€โ”€ reports/
โ”‚       โ”œโ”€โ”€ HtmlReportUtils.py       # HTML generation
โ”‚       โ””โ”€โ”€ EmailReportUtils.py      # Email notifications (future)
โ””โ”€โ”€ templates/
    โ””โ”€โ”€ html_report/
        โ”œโ”€โ”€ html_template.html       # Main template
        โ””โ”€โ”€ components/
            โ”œโ”€โ”€ summary-chart.html
            โ”œโ”€โ”€ category-chart.html
            โ”œโ”€โ”€ phase-chart.html
            โ”œโ”€โ”€ center-chart.html
            โ”œโ”€โ”€ status-center-chart.html
            โ””โ”€โ”€ results-table.html

Data Flow

  1. Tests execute via pytest (with optional xdist parallelization)
  2. Plugin captures test results via pytest_runtest_makereport hook
  3. Custom attributes injected via robo_modify_report_row hook
  4. Results aggregated in pytest_sessionfinish
  5. HTML report generated in pytest_unconfigure

Extension Points

Custom Report Metrics

Modify RoboHelper.aggregate_test_results() to compute custom metrics:

def robo_modify_report_row(report_row, test_data):
    """Custom metric: Execution environment"""
    report_row['environment'] = os.getenv('APP_ENV', 'production')
    report_row['execution_date'] = datetime.now().strftime('%Y-%m-%d')

Email Notifications

Extend pytest_unconfigure hook in conftest to send reports via email:

from robo_automation_test_kit.utils.reports.EmailReportUtils import send_report

def pytest_unconfigure(config):
    """Send report via email after test completion"""
    report_path = config.robo_report_path
    send_report(report_path, to_addresses=['team@example.com'])

Troubleshooting

Missing Test Attributes

  • Verify robo_modify_report_row() is defined in conftest.py (not plugin.py)
  • Ensure CSV columns match field names in the hook

Template Not Found

  • Check templates/html_report/ directory exists in project root
  • Verify templates are included in package via MANIFEST.in

CSV Encoding Errors

  • Plugin automatically tries: utf-8-sig โ†’ latin-1 โ†’ utf-8
  • For manual fixes, ensure CSV is UTF-8 encoded

Parallel Execution Issues

  • Verify pytest-xdist is installed: pip install pytest-xdist
  • Check pytest.ini has -n logical option
  • Disable via PARALLEL_EXECUTION=N or -n 1

Common Commands

# Run all tests with default parallel execution
pytest

# Run serially (no parallelization)
pytest -n 1

# Run specific test
pytest tests/test_example.py::test_function

# Run with verbose output
pytest -v

# Run with specific log level
pytest --log-cli-level=DEBUG

# Run only failed tests from last run
pytest --lf

# Show print statements
pytest -s

# Generate report with custom title
pytest --robo-report-title="Custom Title"

Development

Local Development Setup

# Install in editable mode with all dev dependencies
poetry install

# Run tests
poetry run pytest

# Build package
poetry build

# Publish to PyPI (requires credentials)
poetry publish

Prerequisites

  • Python 3.8+
  • pytest >= 7.4.0
  • pandas >= 2.2.0
  • jinja2 >= 3.0.0

License

Apache License 2.0 - see LICENSE file for details

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes and add tests
  4. Commit with clear messages (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Support

For issues, questions, or suggestions:

  • Open an issue on GitHub
  • Check existing documentation
  • Review test examples in tests/ directory

Related Projects

Changelog

Version 1.0.0 (2026-02-03)

  • Initial release
  • Pytest plugin with HTML reporting
  • CSV/Excel parametrization
  • Parallel execution support (xdist)
  • Interactive chart visualizations
  • Customizable report attributes

Happy Testing! ๐Ÿงช

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

robo_automation_test_kit-1.0.6.tar.gz (113.2 kB view details)

Uploaded Source

Built Distribution

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

robo_automation_test_kit-1.0.6-py3-none-any.whl (121.1 kB view details)

Uploaded Python 3

File details

Details for the file robo_automation_test_kit-1.0.6.tar.gz.

File metadata

  • Download URL: robo_automation_test_kit-1.0.6.tar.gz
  • Upload date:
  • Size: 113.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.1 Linux/6.8.0-1030-azure

File hashes

Hashes for robo_automation_test_kit-1.0.6.tar.gz
Algorithm Hash digest
SHA256 10cf90d5a0d13941e35db114eae56c49f33088e7add8d8b2ad6d6aa16069e05a
MD5 91064601aa56ce87e4a8ba7e18a6f286
BLAKE2b-256 0c487fad6b38b65ccdf05569f0f08b411ffbb6053a1efb6cc7a4a2225d57a453

See more details on using hashes here.

File details

Details for the file robo_automation_test_kit-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for robo_automation_test_kit-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 03ff256ee0e38b4346050458af71d069186e21b06bb555186b9d54245b7a1a57
MD5 52f952824660a448fedcbbc640cb2104
BLAKE2b-256 b6926bfc27e1b5eb58660d1d94eb5f8defffa19dfed06de11868fcc7e43ea709

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