Issue Tracking¶
The HILSTER Testing Framework seamlessly integrates issue tracking systems.
JIRA (Atlassian)¶
The integration of JIRA issues can easily be realized using
htf.JIRAConnector
.
In JIRA the option 'Allow Remote API Calls'
must be enabled.
The htf.JIRAConnector
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 htf.JIRAConnector
add it as a base class for you testcase.
This will provide the method htf.JIRAConnector.setup_jira_connector()
which must be called from the __init__
method of your testcase and supplies
needed information about the JIRA-Url and authentication credentials.
By default htf.JIRAConnector
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 flattend 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.
Example:
import htf
class MyTestCase(htf.TestCase, htf.JIRAConnector):
def __init__(self, methodName="runTest"):
super(Test, self).__init__(methodName=methodName)
self.setup_jira_connector(
url="https://jira.atlassian.com",
project="11460"
)
class Tests(MyTestCase):
def test_foo(self):
pass
To enable debugging use the following code snippet.
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.
JIRAConnector
(*args, **kwargs)¶ The
htf.JIRAConnector
searches JIRA using the rest api to find issues for the current test. Found issues are append to the test and put into the test report.-
setup_jira_connector
(url, project, username=None, password=None, auth=None, oauth_dict=None, kerberos_options=None, query_template=None, title_template=None)¶ Set up the
JIRAConnector
so that it will search you JIRA installation for issues for the current test.Parameters: - url (str) – the url to you JIRA installation
- project (str) – the JIRA project
- username=None (str or None) – the username to be used for authentication
- password=None (str or None) – the password to be used for authentication
- auth=None (str or None) –
possible values are:
None
: no authentication is usedauth
: cookie based authenticationbasic_auth
: HTTP basic authenticationoauth
: OAuth authentication is used (you have to supplyoauth_dict
, too)kerberos
: Kerberos authentication (you have to supplykerberos_options
, too)
- oauth_dict=None (dict) – options for
oauth
authentication - kerberos_options=None (dict) – options for
kerberos
authentication - query_template="default" (str) –
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 projectdefault: “project={project} and (summary~”{testcase}.{test}” or description~”{testcase}.{test}”)”
- title_template="default" (str) – The template for the resulting title of the link in the test report.
The issue is flattend using
'/'
as the separator. So the template may include keys like{fields/status/name}
to show the name of the current ticket status, etc.
-