Skip to main content

A pytest plugin for creating incremental XML test reports for Testhide system.

Project description

Testhide Pytest Plugin

A professional-grade pytest plugin that generates robust JUnit-style XML reports. This plugin was designed to solve real-world CI/CD challenges by ensuring data integrity during test failures and providing full support for parallel test execution.

Key Features

  • Incremental Reporting: Every single test result is saved immediately, guaranteeing that partial results are available even if a test run is catastrophically interrupted.
  • Full pytest-xdist Compatibility: The plugin uses a robust temporary file and merge strategy, enabling it to work flawlessly with parallel test execution (-n X).
  • pytest-rerunfailures Support: Every rerun of a failing test is logged as a separate <testcase> in the final report, providing a complete and accurate picture of flaky tests.
  • JIRA Integration: Automatically enriches failure reports with information from JIRA, linking test failures to known bugs and their statuses.
  • Clean Stack Traces: Automatically removes internal "noise" from pytest and pluggy calls in stack traces, leaving only the relevant information from your application and test code.
  • Atomic & Safe Writes: Uses a temporary directory and a final, atomic merge to ensure the report file is never corrupted, even under heavy load or across multiple concurrent builds on the same agent.

Installation

pip install testhide-pytest-plugin

Usage

Basic Run

To activate the plugin and generate a report, use the --report-xml option:

pytest --report-xml=junittests.xml

Parallel Execution (pytest-xdist)

The plugin is fully compatible with pytest-xdist out of the box. Simply add the -n flag to run tests in multiple processes. The plugin will automatically handle and merge the results from all worker nodes.

pytest -n auto --report-xml=junittests.xml

Rerunning Failed Tests (pytest-rerunfailures)

The plugin works seamlessly with pytest-rerunfailures. Every attempt of a failing test will be recorded in the final report, allowing for accurate tracking of test instability.

pytest --reruns 5 --report-xml=junittests.xml

JIRA Integration

To enable JIRA integration, simply provide the connection details as command-line options. Integration is enabled automatically when all three parameters are present.

  • --jira-url: The URL of your JIRA instance.
  • --jira-username: The username for the connection.
  • --jira-password: The password or API token for the user.
pytest --report-xml=junittests.xml \
       --jira-url="[https://jira.yourcompany.com](https://jira.yourcompany.com)" \
       --jira-username="my-bot" \
       --jira-password="your-api-token"

Extending the Plugin (For Framework Developers)

testhide-pytest-plugin provides custom hooks for integration with your own plugins, allowing you to inject project-specific metadata into the report.

Example implementation in your plugin:

pytest_testhide_add_metadata(plugin)

This hook allows you to add metadata at the session level (e.g., build information, branch name, etc.). It must return a list of (name, value) tuples.

from pytest import hookimpl

class MyFrameworkPlugin:
    @hookimpl
    def pytest_testhide_add_metadata(self, plugin):
        return [
            ('build', '1.2.3'),
            ('branch', 'develop')
        ]

pytest_testhide_get_test_case_properties(item, report)

This hook allows you to add data at the individual test case level (e.g., a docstring, steps to reproduce, or artifact links). It must return a list of (name, value) tuples.

from pytest import hookimpl

class MyFrameworkPlugin:
    @hookimpl
    def pytest_testhide_get_test_case_properties(self, item, report):
        properties = []
        if item.obj and item.obj.__doc__:
            properties.append(('docstr', item.obj.__doc__.strip()))
        
        # Example of adding an artifact link
        if hasattr(item, 'artifact_url'):
            properties.append(('attachment', item.artifact_url))
            
        return properties

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

testhide_pytest_plugin-0.2.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

testhide_pytest_plugin-0.2.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file testhide_pytest_plugin-0.2.0.tar.gz.

File metadata

  • Download URL: testhide_pytest_plugin-0.2.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for testhide_pytest_plugin-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f221e2cdfd249fc62c8625dc212def7df547c0a225d7d87cb05f382366ba61d8
MD5 9505754083b6423896934601d7cbcf7e
BLAKE2b-256 c0472fbdebf159880b624fd6be54d1348613e864d9b8705c31ee959aaa672cc4

See more details on using hashes here.

File details

Details for the file testhide_pytest_plugin-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for testhide_pytest_plugin-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 533abaca1b82e02a760eb7e49b10892c43a458b99a252180bf2b1494c31f01a3
MD5 f42b4a418397f42dbc701545255c6968
BLAKE2b-256 0c5792101644909d611a546072515910a9a38c4303f5ca1dab4096fcf259c084

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