Skip to main content

Plugin skips (xfail) tests if unresolved Jira issue(s) linked

Project description

pytest-jira-xfail

Plugin skips (xfail) tests linked to unresolved Jira issue(s)

1. Generate your Jira API token

You should have Jira user with API token generated

2. Add PytestJiraHelper to your pytest hook:

import pytest

from pytest_jira_xfail.jira_helper import PytestJiraHelper


@pytest.hookimpl(tryfirst=True)
def pytest_collection_modifyitems(items):
    jira = PytestJiraHelper(
        jira_url="https://company.atlassian.net",
        jira_username="my_jira_user@company.com",
        jira_api_token="my_jira_user_api_token",
    )
    jira.process_linked_jira_issues(items)

3. Link bugs to your tests

from pytest_jira_xfail.annotations import bug


@bug("MP-123")
def test_my_test_fails():
    assert False


@bug("MP-124", IndexError)
def test_my_test_broken():
    db_records = []
    assert db_records[0]


@bug("MP-124")
@bug("MP-124", IndexError)
def test_multiple_exceptions():
    db_records = []
    assert db_records[0][0] == 'active'

XFAIL message format:

XFAIL The test is skipped because of open bugs:
https://company.atlassian.net/browse/MP-123

4. [Optional] Set custom resolved statuses

By default, only issues with the status "Done" and "Closed" are considered as resolved.
But you can override this and add more statuses, as following:

import pytest

from pytest_jira_xfail.jira_helper import PytestJiraHelper


@pytest.hookimpl(tryfirst=True)
def pytest_collection_modifyitems(items):
    jira = PytestJiraHelper(
        jira_url="https://company.atlassian.net",
        jira_username="my_jira_user@company.com",
        jira_api_token="my_jira_user_api_token",
        resolved_statuses=["Done", "Closed", "Released", "Declined"]
    )
    jira.process_linked_jira_issues(items)

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_jira_xfail-1.2.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

pytest_jira_xfail-1.2.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest_jira_xfail-1.2.1.tar.gz.

File metadata

  • Download URL: pytest_jira_xfail-1.2.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for pytest_jira_xfail-1.2.1.tar.gz
Algorithm Hash digest
SHA256 9abd122697f53eaf6d429420fa597e2515458140e5c4733008d6bdb3d8763f6b
MD5 8e0bce9c66a3b184f0aeaead9b6d0a8a
BLAKE2b-256 0bf6b161c8d78ca611478423fb49604e801fc4277974b4c43ed7f2dd81495a89

See more details on using hashes here.

File details

Details for the file pytest_jira_xfail-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_jira_xfail-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88f7736b360853e484f4fab380a528bebc5bafd4189b62a52dd6357cbe1fbd7a
MD5 c03facf9e24c1a4f967ea5bb189967d5
BLAKE2b-256 78b40f01ee3cbae364faaa8cf9d21af2df65c095b7265b16c0eef02ee46dac47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page