Create a new test run.
:param project_key: project key of the test run ex. "TEST"
:type project_key: str
:param test_run_name: name of the test run to be created
:type test_run_name: str
:param kwargs: Arbitrary list of keyword arguments
folder: name of the folder where to create the new test run
issue_key: issue key to link this test run to
test_plan_key: test plan key to link this test run to
test_cases: list of test case keys to be linked to the test run ex. ["TEST-T1026","TEST-T1027"]
environment: environment to distinguish multiple executions (call get_environments() to get a list of available ones)
:return: key of the test run created
:rtype: str
"""
self.logger.debug("create_test_run(\"%s\", \"%s\")", project_key, test_run_name)
folder = kwargs.pop("folder", None)
issue_key = kwargs.pop("issue_key", None)
test_plan_key = kwargs.pop("test_plan_key", None)
test_cases = kwargs.pop("test_cases", [])
environment = kwargs.pop("environment", None)
assert not kwargs, "Unknown arguments: %r" % kwargs
folder = ("/" + folder).replace("//", "/") if folder else folder or None
if folder and folder not in self.get_folders(project_key=project_key, folder_type="TEST_RUN"):
self.create_folder(project_key=project_key, folder_type="TEST_RUN", folder_name=folder)
test_cases_list_of_dicts = []
for test_case_key in test_cases:
test_cases_list_of_dicts.append({"testCaseKey": test_case_key, "environment": environment, "executedBy": get_executor(), "assignedTo": get_executor()})
request_url = self.adaptavist_api_url + "/testrun"
request_data = {"projectKey": project_key,
"testPlanKey": test_plan_key,
"name": test_run_name,
"folder": folder,
"issueKey": issue_key,
"items": test_cases_list_of_dicts}
try:
request = requests.post(request_url,
auth=self.authentication,
headers=self.headers,
data=json.dumps(request_data))
request.raise_for_status()
except HTTPError as ex:
# HttpPost: in case of status 400 request.text contains error messages
self.logger.error("request failed. %s %s", ex, request.text)
return None
except (requests.exceptions.ConnectionError, requests.exceptions.RequestException) as ex:
self.logger.error("request failed. %s", ex)
return None
response = request.json()
return response["key"]`
` def create_test_run(self, project_key, project_id, test_run_name, **kwargs):
"""
Create a new test run.
:param project_key: project key of the test run ex. "TEST"
:type project_key: str
:param project_id: project id of the test run ex. "TEST"
:type project_id: str
:param test_run_name: name of the test run to be created
:type test_run_name: str
:param kwargs: Arbitrary list of keyword arguments
folder: name of the folder where to create the new test run
issue_key: issue key to link this test run to
test_plan_key: test plan key to link this test run to
test_cases: list of test case keys to be linked to the test run ex. ["TEST-T1026","TEST-T1027"]
environment: environment to distinguish multiple executions (call get_environments() to get a list of
available ones)
:return: key of the test run created
:rtype: str
"""
self.logger.debug("create_test_run(\"%s\", \"%s\", \"%s\")", project_key, project_id, test_run_name)
folder = kwargs.pop("folder", None)
issue_key = kwargs.pop("issue_key", None)
test_plan_key = kwargs.pop("test_plan_key", None)
test_plan_id = kwargs.pop("test_plan_id", None)
test_cases = kwargs.pop("test_cases", [])
environment = kwargs.pop("environment", None)
time = kwargs.pop("time", None)
assert not kwargs, "Unknown arguments: %r" % kwargs
folder_name = ("/" + folder).replace("//", "/") if folder else folder or None
folder_id = self.create_folder_plan(project_id=project_id, project_key=project_key, folder_type="TEST_PLAN",
folder_name=folder_name)
test_cases_list_of_dicts = []
for test_case_key in test_cases:
test_cases_list_of_dicts.append({"testCaseKey": test_case_key, "environment": environment, "executedBy": get_executor(), "assignedTo": get_executor()})
request_url = self.adaptavist_api_url + "/testrun"
request_data = {"projectId": project_id,
"testPlanId": test_plan_id,
"name": test_run_name,
"folderId": folder_id if folder_id else None,
"issueKey": issue_key,
"items": test_cases_list_of_dicts,
"plannedEndDate": time,
"plannedStartDate": time,
}
try:
request = requests.post(request_url,
auth=self.authentication,
headers=self.headers,
data=json.dumps(request_data),
verify=False)
request.raise_for_status()
except HTTPError as ex:
# HttpPost: in case of status 400 request.text contains error messages
self.logger.error("request failed. %s %s", ex, request.text)
return None
except (requests.exceptions.ConnectionError, requests.exceptions.RequestException) as ex:
self.logger.error("request failed. %s", ex)
return None
response = request.json()
self.lint_test_case(test_cases)
return response["key"], response["id"]`
so for now this library is not equal.
If you need other data - maybe we have old version TM4J server plugin