Skip to main content

Markdown test report formatter for pytest-bdd with pytest-playwright screenshot support

Project description

pytest-bdd-md-report

Markdown test report formatter for pytest-bdd with pytest-playwright screenshot support.

Installation

pip install pytest-bdd-md-report

Or with uv:

uv add pytest-bdd-md-report

Optional dependencies

# With pytest-playwright support (for screenshot capture)
pip install pytest-bdd-md-report[playwright]

# With pytest-bdd support
pip install pytest-bdd-md-report[bdd]

# All optional dependencies
pip install pytest-bdd-md-report[all]

Quick Start

# Generate a markdown report
pytest --markdown-report=test_report.md

# Include detailed step information (Given/When/Then)
pytest --markdown-report=test_report.md --markdown-report-verbose

# Include screenshots for failed tests (requires pytest-playwright)
pytest --markdown-report=test_report.md --markdown-report-screenshots --screenshot=only-on-failure

CLI Options

Option Description
--markdown-report=path Output path for the Markdown report (required to enable)
--markdown-report-verbose Include detailed step information (Given/When/Then)
--markdown-report-template=path Custom Jinja2 template file path
--markdown-report-screenshots Embed failure screenshots in report
--markdown-report-embed-images Base64 encode screenshots directly in markdown

Output Example

Basic Mode

## Summary
- **Total Tests**: 3
- **Passed**: 2
- **Failed**: 1

## Test Results

### Feature: Login

#### [PASS] Scenario: Successful login
- **Status**: PASSED
- **Duration**: 1.73s

Verbose Mode (--markdown-report-verbose)

#### [PASS] Scenario: Successful login
- **Status**: PASSED
- **Duration**: 1.73s

**Steps:**
1. [PASS] **Given** the login page is displayed (0.45s)
2. [PASS] **When** user enters valid credentials (0.98s)
3. [PASS] **Then** dashboard is shown (0.30s)

Custom Templates

Create a custom Jinja2 template to customize the report format.

Template Variables

Variable Type Description
generation_time str Report generation timestamp
summary.total_tests int Total test count
summary.passed int Passed count
summary.failed int Failed count
summary.skipped int Skipped count
summary.total_duration str Total execution time
features dict Feature name to scenario list mapping

Example Custom Template

# Test Report

Generated: {{ generation_time }}

| Metric | Value |
|--------|-------|
| Total | {{ summary.total_tests }} |
| Passed | {{ summary.passed }} |
| Failed | {{ summary.failed }} |

{% for feature_name, scenarios in features.items() %}
## {{ feature_name }}

{% for scenario in scenarios %}
- **{{ scenario.scenario_name }}**: {{ scenario.status }}
{% endfor %}
{% endfor %}

Screenshot Support

Capture screenshots for failed tests using pytest-playwright:

# Screenshots saved as file references
pytest --markdown-report=test_report.md --markdown-report-screenshots --screenshot=only-on-failure

# Screenshots embedded as Base64 (single-file report)
pytest --markdown-report=test_report.md --markdown-report-screenshots --markdown-report-embed-images --screenshot=only-on-failure

Note: --screenshot=only-on-failure is a pytest-playwright option. Screenshots are saved to test-results/ directory.

Requirements

  • Python >= 3.10
  • pytest >= 7.0.0
  • jinja2 >= 3.1.0

Optional

  • pytest-bdd >= 6.0.0 (for BDD-style tests)
  • pytest-playwright >= 0.4.0 (for screenshot capture)

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_bdd_md_report-1.0.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

pytest_bdd_md_report-1.0.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest_bdd_md_report-1.0.1.tar.gz.

File metadata

  • Download URL: pytest_bdd_md_report-1.0.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pytest_bdd_md_report-1.0.1.tar.gz
Algorithm Hash digest
SHA256 238391d54ba374b55958d43276b27158f07be29566f4b26b74408e1ad45eeb9d
MD5 730917c1352657b9d9f6ff5d46f77ed2
BLAKE2b-256 aed6595491a276ab7a8ed2056fca4a3aa07cb3b0f321468f2d62cfe4a3d8bc15

See more details on using hashes here.

File details

Details for the file pytest_bdd_md_report-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_bdd_md_report-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e15bc13c2dfaac57fde5fe86ea69024f961dfc17b030521d4989cbb6986050b0
MD5 238b6ea79d0ee424d5a6eb161defa13f
BLAKE2b-256 cdf0937f2fd34f765cc05f80b441bf1b62f5a00f506dabbf60c9e7ed4b756cef

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