Skip to main content

A pytest plugin for requirement coverage tracking

Project description

pytest-reqcov

A pytest plugin for requirement coverage tracking.

Features

  • Track test coverage against requirements and products
  • Integrate with pytest workflow

Installation

Install from PyPI:

pip install pytest-reqcov

Usage

Add requirement markers to your tests:

import pytest

@pytest.mark.req(id="REQ-001")
def test_user_login():
    """Test user login functionality."""
    assert login_user("user", "password") == True

@pytest.mark.product(id="ProductA")
def test_user_logout():
    """Test user logout functionality."""
    assert logout_user() == True

Run pytest with requirement coverage:

pytest --reqcov-reqs=requirements.csv --reqcov-prods=products.csv  --reqcov-output=output.csv

Merging Multiple Coverage Reports

When running tests across multiple test suites or environments, you can merge the generated coverage reports using the reqcov-merge command:

# Merge multiple output files
reqcov-merge output1.csv output2.csv output3.csv -o merged_output.csv

# Merge with verbose output
reqcov-merge output1.csv output2.csv -o merged_output.csv --verbose

The merge script applies the AND operator for status determination:

  • If all tests for a requirement/product are PASSED, the merged status is PASSED
  • If any test for a requirement/product is FAILED, the merged status is FAILED
  • Tests from multiple files are combined into a comma-separated list

Example merge scenario:

# output1.csv
item;type;status;tests
REQ001;requirement;PASSED;test_req_1
Product_A;product;PASSED;test_product_a1

# output2.csv
item;type;status;tests
REQ001;requirement;FAILED;test_req_2
Product_A;product;PASSED;test_product_a2

# merged_output.csv (result)
item;type;status;tests
REQ001;requirement;FAILED;test_req_1,test_req_2
Product_A;product;PASSED;test_product_a1,test_product_a2

Configuration

Add configuration to your pytest.ini or pyproject.toml:

[tool.pytest.ini_options]
markers = [
    "req: tests with associated requirements",
    "product: tests with associated product",
]

License

This project is licensed under the MIT License - see the LICENSE file for details.

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_reqcov-0.2.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

pytest_reqcov-0.2.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_reqcov-0.2.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytest_reqcov-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fc4fbec15cb960d5516c88e8a3aa9613671fcd0e868081bb8ffcb3640991bb6f
MD5 3daab5fd85120648c0d3833d29b518a0
BLAKE2b-256 00755afc092dfad9a683ad011924bb88187316b8e49e39578b7f4c7375af4b6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_reqcov-0.2.0.tar.gz:

Publisher: ci-cd.yml on mgfernan/pytest_reqcov

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: pytest_reqcov-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytest_reqcov-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c678bececdefd5b05ee2366b6c44f7b0d1f1be0e4405116c0b375298cc982f15
MD5 7c0b5299179b7512306dd085f379e4de
BLAKE2b-256 bcce03460c771a8fbfe354035ebbc37b66013c408159d0a181f7a119eca72ab5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_reqcov-0.2.0-py3-none-any.whl:

Publisher: ci-cd.yml on mgfernan/pytest_reqcov

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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