Metadata-Version: 2.1
Name: pytest-jira-xfail
Version: 1.2.0
Summary: Plugin skips (xfail) tests if unresolved Jira issue(s) linked
Home-page: https://github.com/JamalZeynalov/pytest-jira-xfail
Author: Jamal Zeinalov
Author-email: jamal.zeynalov@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pytest>=7.2.0
Requires-Dist: requests>=2.28.1
Requires-Dist: setuptools>=65.5.1
Requires-Dist: jira>=3.4.1
Requires-Dist: singleton-decorator>=1.0.0
Requires-Dist: allure-pytest>=2.11.1
Requires-Dist: selenium>=4.6.0
Requires-Dist: pytest-playwright>=0.3.3
Requires-Dist: playwright~=1.43.0

# 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](https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/)

## 2. Add PytestJiraHelper to your pytest hook:

```python
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

```python
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.<br>
But you can override this and add more statuses, as following:

```python
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)
```
