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.0.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

pytest_jira_xfail-1.0.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest-jira-xfail-1.0.2.tar.gz.

File metadata

  • Download URL: pytest-jira-xfail-1.0.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for pytest-jira-xfail-1.0.2.tar.gz
Algorithm Hash digest
SHA256 401a43ddaf2e5baf4158dcafb5cf940642a71d3534bd87a0fbc90d620a79cc56
MD5 5fce57c48acbdb7716d24ec4cf9973fa
BLAKE2b-256 159b2acb786c44e85e30c67577c6abb05a3f1afb0bb2abb6b8aa264b4683b181

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_jira_xfail-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 09e1b9fc7cf303e641dc4c7f908e9bab0ea78a052432a21c78b507d992435eeb
MD5 960fbf0531c179d36f919cdf4b59b5e0
BLAKE2b-256 9d16671e1c384ee0b1228a58da9f945e64ee47b474a7e6712709d684057f2993

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