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'
Skip the test entirely (never run it)
By default a test linked to an open bug is still executed and reported as XFAIL
(so an unexpected pass shows up as XPASS). If the bug makes the test unsafe or
pointless to run (e.g. it hangs, corrupts data, or blocks the suite), pass
run=False to skip execution completely while the issue is open. The test is
reported as XFAIL [NOTRUN] and its body is never executed:
from pytest_jira_xfail.annotations import bug
@bug("MP-123", run=False)
def test_not_executed_until_fixed():
assert False # never runs while MP-123 is open
Once the linked issue is resolved, the test runs normally again.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_jira_xfail-1.3.0.tar.gz.
File metadata
- Download URL: pytest_jira_xfail-1.3.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e05771dd7b30328de7ae3e996734d1cef945e77067668cc96ac9e653aecba5c
|
|
| MD5 |
6c9e279c123eb0323a147f445870b583
|
|
| BLAKE2b-256 |
7fa79c71657f9ba7dac7c3ce6a77a23601c3d54871a9dc5d82fbeac3a06b0dd4
|
File details
Details for the file pytest_jira_xfail-1.3.0-py3-none-any.whl.
File metadata
- Download URL: pytest_jira_xfail-1.3.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bdf373ee4640b6e5674a0f6a9c30885b35964ef00828b4f5b62e9b1922c4e4c
|
|
| MD5 |
492c8c229849c8395fb667433c260bbb
|
|
| BLAKE2b-256 |
22f9d46b4bbc2f26968e2c2fb842bffec085df10207603cf6c2475da24d17596
|