diff --git a/README.md b/README.md index 1a984e2..f89d5ea 100644 --- a/README.md +++ b/README.md @@ -257,6 +257,7 @@ You can use environment variable to control certain features of testomat.io | TESTOMATIO_RUNGROUP_TITLE | Create a group (folder) for a test run. If group already exists, attach test run to it | TESTOMATIO_RUNGROUP_TITLE="Release 2.0" pytest --testomatio report | | TESTOMATIO_ENV | Assign environment to a test run, env variant of **testRunEnv** option. Has a lower precedence than **testRunEnv** option. | TESTOMATIO_ENV="linux,chrome,1920x1080" pytest --testomatio report | | TESTOMATIO_LABEL | Assign labels to a test run. Labels must exist in project and their scope must be enabled for runs | TESTOMATIO_LABEL="smoke,regression" pytest --testomatio report | +| TESTOMATIO_JIRA_ID | Assigns Test Run to Jira Issue. Note: Issue must exist on Jira and Jira Integration must be configured for project on Testomat.io | TESTOMATIO_JIRA_ID=TES-1 pytest --testomatio report | | TESTOMATIO_UPDATE_CODE | Send code of your test to Testomat.io on each run. If not enabled(default) assumes the code is pushed using **sync** command | TESTOMATIO_UPDATE_CODE=True pytest --testomatio report | | TESTOMATIO_EXCLUDE_SKIPPED | Exclude skipped tests from the report | TESTOMATIO_EXCLUDE_SKIPPED=1 pytest --testomatio report | | TESTOMATIO_PUBLISH | Publish run after reporting and provide a public URL | TESTOMATIO_PUBLISH=true pytest --testomatio report | diff --git a/pytestomatio/connect/connector.py b/pytestomatio/connect/connector.py index 52c8e80..73ae847 100644 --- a/pytestomatio/connect/connector.py +++ b/pytestomatio/connect/connector.py @@ -185,7 +185,7 @@ def get_tests(self, test_metadata: list[TestItem]) -> dict: log.error('Failed to get test ids from testomat.io') - def create_test_run(self, access_event: str, title: str, group_title, env: str, label: str, shared_run: bool, shared_run_timeout: str, + def create_test_run(self, access_event: str, title: str, group_title, jira_id: str, env: str, label: str, shared_run: bool, shared_run_timeout: str, parallel, ci_build_url: str) -> dict | None: request = { "access_event": access_event, @@ -193,6 +193,7 @@ def create_test_run(self, access_event: str, title: str, group_title, env: str, "title": title, "group_title": group_title, "env": env, + "jira_id": jira_id, "label": label, "parallel": parallel, "ci_build_url": ci_build_url, @@ -213,7 +214,7 @@ def create_test_run(self, access_event: str, title: str, group_title, env: str, return response.json() self._show_status_message(response.status_code) - def update_test_run(self, id: str, access_event: str, title: str, group_title, + def update_test_run(self, id: str, access_event: str, title: str, group_title, jira_id: str, env: str, label: str, shared_run: bool, shared_run_timeout: str, parallel, ci_build_url: str) -> dict | None: request = { "access_event": access_event, @@ -221,6 +222,7 @@ def update_test_run(self, id: str, access_event: str, title: str, group_title, "title": title, "group_title": group_title, "env": env, + "jira_id": jira_id, "label": label, "parallel": parallel, "ci_build_url": ci_build_url, diff --git a/pytestomatio/testomatio/testRunConfig.py b/pytestomatio/testomatio/testRunConfig.py index f74a097..19960f1 100644 --- a/pytestomatio/testomatio/testRunConfig.py +++ b/pytestomatio/testomatio/testRunConfig.py @@ -26,6 +26,7 @@ def __init__(self): self.exclude_skipped = exclude_skipped self.label = safe_string_list(os.environ.get('TESTOMATIO_LABEL')) self.group_title = os.environ.get('TESTOMATIO_RUNGROUP_TITLE') + self.jira_id = os.environ.get('TESTOMATIO_JIRA_ID') # This allows to report tests to the test run by it's id. https://docs.testomat.io/getting-started/running-automated-tests/#reporting-parallel-tests self.parallel = False if shared_run else True # This allows using test run title to group tests under a single test run. This is needed when running tests in different processes or servers. @@ -45,6 +46,7 @@ def to_dict(self) -> dict: result['title'] = self.title result['group_title'] = self.group_title result['env'] = self.environment + result['jira_id'] = self.jira_id result['label'] = self.label result['parallel'] = self.parallel result['shared_run'] = self.shared_run diff --git a/tests/test_connect/test_connector.py b/tests/test_connect/test_connector.py index 7fdc4a1..0e37630 100644 --- a/tests/test_connect/test_connector.py +++ b/tests/test_connect/test_connector.py @@ -307,6 +307,7 @@ def test_create_test_run_success(self, mock_post, connector): group_title="Group 1", env="linux,chrome", label="smoke", + jira_id="tes-1", shared_run=False, shared_run_timeout="2", parallel=True, @@ -321,6 +322,7 @@ def test_create_test_run_success(self, mock_post, connector): "title": "Test Run", "group_title": "Group 1", "env": "linux,chrome", + "jira_id": "tes-1", "label": "smoke", "shared_run": False, "shared_run_timeout": "2", @@ -345,6 +347,7 @@ def test_create_test_run_filters_none_values(self, mock_post, connector): group_title=None, env=None, label="smoke", + jira_id=None, shared_run=False, shared_run_timeout=None, parallel=True, @@ -366,7 +369,7 @@ def test_create_test_run_http_error(self, mock_post, connector): """Test HTTP error handled wher create test run""" mock_post.side_effect = HTTPError("HTTP Error") - result = connector.create_test_run("Test", None, None, None, None, False, True, None, None) + result = connector.create_test_run("Test", None, None, None, None, None, False, True, None, None) assert result is None @patch('requests.Session.put') @@ -383,6 +386,7 @@ def test_update_test_run_success(self, mock_put, connector): title="Updated Run", group_title="Group", env="windows", + jira_id="tes-1", label="regression", shared_run=True, shared_run_timeout='2', @@ -398,6 +402,7 @@ def test_update_test_run_success(self, mock_put, connector): "title": "Updated Run", "group_title": "Group", "env": "windows", + "jira_id": "tes-1", "label": "regression", "shared_run": True, "shared_run_timeout": '2', diff --git a/tests/test_testomatio/test_testRunConfig.py b/tests/test_testomatio/test_testRunConfig.py index fdb9d78..e265039 100644 --- a/tests/test_testomatio/test_testRunConfig.py +++ b/tests/test_testomatio/test_testRunConfig.py @@ -24,6 +24,7 @@ def test_init_default_values(self): assert config.disable_batch is False assert config.batch_size == DEFAULT_BATCH_SIZE assert config.label is None + assert config.jira_id is None assert config.group_title is None assert config.parallel is True assert config.shared_run is False @@ -40,6 +41,7 @@ def test_init_with_env_variables(self): 'TESTOMATIO_ENV': 'linux,browser:chrome,1920x1080', 'TESTOMATIO_LABEL': 'smoke,regression', 'TESTOMATIO_RUNGROUP_TITLE': 'Release 2.0', + 'TESTOMATIO_JIRA_ID': 'TES-1', 'TESTOMATIO_UPDATE_CODE': '1', 'TESTOMATIO_PUBLISH': '1', 'TESTOMATIO_EXCLUDE_SKIPPED': '1', @@ -61,6 +63,7 @@ def test_init_with_env_variables(self): assert config.group_title == 'Release 2.0' assert config.parallel is True assert config.shared_run is False + assert config.jira_id == 'TES-1' assert config.update_code is True assert config.meta == {'linux': None, 'browser': 'chrome', '1920x1080': None} @@ -157,6 +160,7 @@ def test_to_dict_full_data(self): 'TESTOMATIO_LABEL': 'label1,label2', 'TESTOMATIO_RUNGROUP_TITLE': 'Group 1', 'TESTOMATIO_SHARED_RUN': 'true', + 'TESTOMATIO_JIRA_ID': "TES-1", 'TESTOMATIO_SHARED_RUN_TIMEOUT': "12", 'TESTOMATIO_PUBLISH': 'true' } @@ -175,6 +179,7 @@ def test_to_dict_full_data(self): 'label': 'label1,label2', 'parallel': False, 'shared_run': True, + 'jira_id': 'TES-1', 'shared_run_timeout': '12', 'ci_build_url': None }