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.3.tar.gz (4.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_jira_xfail-1.0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-jira-xfail-1.0.3.tar.gz
  • Upload date:
  • Size: 4.3 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.3.tar.gz
Algorithm Hash digest
SHA256 64a256fdfdc2aa1ae1f3cfeb48d1819ba97a8c316b89da8c792e7b34039b669e
MD5 e14fb5933ba328c9b2cc8c99cc834553
BLAKE2b-256 7df7448be53d7bd7ec8657cb0a4ab28022bf5e761d96b4b21bdb60ab0f39098e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_jira_xfail-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1418ac763805c3c1b08a05c0a5f1edf9e4854bca0f69fb92952e4f8573fe4c8d
MD5 df0a60b822c75034843fec013539fee7
BLAKE2b-256 e5ac18e61055324d4b7f97103fa592e21ac1e6701cfe2e10590add8d1595f979

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