<!-- HILSTER htf 4.3.1 -->
**htf 4.3.1** · [HTML](../issue_tracking.html) · [Complete PDF manual](../_downloads/htf-4.3.1.pdf)

# Issue Tracking

The HILSTER Testing Framework seamlessly integrates issue tracking systems.

<a id="id1"></a>

## JIRA (Atlassian)

The integration of JIRA issues can easily be realized using the `jira` fixture.

In JIRA the option `'Allow Remote API Calls'` must be enabled.

The `jira` fixture searches JIRA using the rest api to find issues for the current test.
Found issues are appended to the test and put into the test report.

This way you do not need to put your issues into the source code of your tests.

By default issues must include `testcase.test` in the summary or the description, eg. `MyTestCase.test_foo`.
This behaviour can be changed by changing the `query_template` accordingly.

To use the `jira` fixture you need to create your own fixture depending on it to provide
the necessary JIRA URL and authentication credentials. The fixture should have the scope “session” and have the `auto`
parameter set to `True`.

By default the `jira` fixture creates links that include the type, id and status of the
referenced issue, e.g. `Bug TRANS-1266 (Resolved): Dutch language does not reflect on keyboard shortcut dialog box`.

The default template for `link_template` is `"{fields/issuetype/name} {key} ({fields/status/name}): {fields/summary}"`.
The `'/'` in the template describe the hierarchy in the api result.
The api result is flattened and is used to format the template using the `string.format` method.

To be able to see all possible keys you should enable debugging to have a look at the flattend dictionary.

For `oauth` and `kerberos` authentication have a look at the
[python-jira documentation](https://jira.readthedocs.io).

Example:

```python
import htf

@htf.fixture('session', auto=True)
def setup_jira(jira):
    jira.setup_jira_connector(
        url="https://jira.atlassian.com",
        project="11460"
    )

def test_foo():
    pass
```

To enable debugging use the following code snippet.

```python
import logging
logging.basicConfig()
logger = logging.getLogger("htf.jira")
logger.setLevel(level=logging.INFO)  # to enable info
logger.setLevel(level=logging.DEBUG)  # to enable info and debug
```

### *class* htf.fixtures.jira(environment: TestEnvironment)

#### setup_jira_connector(url: [str](https://docs.python.org/3/builtins/stdtypes.html#str), project: [str](https://docs.python.org/3/builtins/stdtypes.html#str), username: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, password: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, auth: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, oauth_dict: [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[Any](https://docs.python.org/3/library/typing.html#typing.Any), [Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None, kerberos_options: [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[Any](https://docs.python.org/3/library/typing.html#typing.Any), [Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None, query_template: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, title_template: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None) → [None](https://docs.python.org/3/builtins/constants.html#None)

Set up the `jira` fixture so that it will search your JIRA installation
for issues for the current test.

* **Parameters:**
  * **url** – the url to your JIRA installation
  * **project** – the JIRA project
  * **username=None** – the username to be used for authentication
  * **password=None** – the password to be used for authentication
  * **auth=None** – 

    possible values are:
    - `None`: no authentication is used
    - `auth`: cookie based authentication
    - `basic_auth`: HTTP basic authentication
    - `oauth`: OAuth authentication is used (you have to supply `oauth_dict`, too)
    - `kerberos`: Kerberos authentication (you have to supply `kerberos_options`, too)
  * **oauth_dict=None** – options for `oauth` authentication
  * **kerberos_options=None** – options for `kerberos` authentication
  * **query_template="default"** – 

    the template for the JIRA query string. supported replacements are
    - `{testcase}`: is replaced with the TestCase’s class name
    - `{test}`: is replaced with the current test name
    - `{project}`: is replaced with the supplied project

    default: “project={project} and (summary~”{testcase}.{test}” or description~”{testcase}.{test}”)”
  * **title_template="default"** – The template for the resulting title of the link in the test report.
    The issue is flattened using `'/'` as the separator. So the template may include keys like
    `{fields/status/name}` to show the name of the current ticket status, etc.
