def suite_summary(self, junit_file): """ To get the name, status and location of both test suite and test case""" tree = xml_Utils.get_tree_from_file(self.junit_file) for values in tree.iter('testsuite'): suite_detail = values.attrib suite_name = suite_detail.get('name') suite_status = suite_detail.get('status') suite_location = suite_detail.get('suite_location') suite_result_dir = suite_detail.get('resultsdir') if suite_location is not None: print_info("{0:10}{1:50}{2:10}{3:30}".format( "Suites", suite_name, suite_status, suite_location)) for value in tree.iter('testcase'): testcase_details = value.attrib testcase_status = testcase_details.get('status') testcase_name = testcase_details.get('name') + ".xml" testcase_location = testcase_details.get('testcasefile_path') case_result_dir_with_tc_name = testcase_details.get( 'resultsdir') if case_result_dir_with_tc_name is not None: case_result_dir = os.path.dirname( case_result_dir_with_tc_name) # suite junit element will not have resultsdir attrib for case execution if suite_result_dir is None or suite_result_dir == case_result_dir: print_info("{0:10}{1:50}{2:10}{3:30}".format( "Testcase", testcase_name, testcase_status, testcase_location))
def suite_summary(self, junit_file): """ To get the name, status and location of both test suite and test case""" tree = xml_Utils.get_tree_from_file(self.junit_file) suite_tc_list = [] for values in tree.iter('testsuite'): suite_detail = values.attrib suite_name = suite_detail.get('name') suite_status = suite_detail.get('status') suite_location = suite_detail.get('suite_location') suite_result_dir = suite_detail.get('resultsdir') if suite_location is not None: suite_tc_list.append( ["Suites", suite_name, suite_status, suite_location]) for value in tree.iter('testcase'): testcase_details = value.attrib testcase_status = testcase_details.get('status') testcase_name = testcase_details.get('name') + ".xml" testcase_location = testcase_details.get('testcasefile_path') case_result_dir_with_tc_name = testcase_details.get( 'resultsdir') if case_result_dir_with_tc_name is not None: case_result_dir = os.path.dirname( case_result_dir_with_tc_name) # suite junit element will not have resultsdir attrib for case execution if suite_result_dir is None or suite_result_dir == case_result_dir: suite_tc_list.append([ "Testcase", testcase_name, testcase_status, testcase_location ]) # suite_tc_list appends suites and test cases as per execution order return suite_tc_list
def get_file_type(self, junit_file): """To get the file type which is given for execution""" tree = xml_Utils.get_tree_from_file(self.junit_file) for names in tree.iter('testsuites'): file_detail = names.attrib file_val = file_detail.get('name') if file_val == "customProject_independant_testcase_execution": file_type = "Suites" else: file_type = "Project" return file_type
def update_issue_in_resultxml(cls, result_xml_file, issue_id, step_num): """ Update the issue-id under the corresponding step in the testcase result xml file """ tree = xml_Utils.get_tree_from_file(result_xml_file) keywords = tree.findall('Keyword') for keyword in keywords: step = keyword.find('Step') if step is not None: ts_num = step.get('step_num') if ts_num == str(step_num): defect = xml_Utils.create_subelement(step, 'Defect', {}) defect.text = str(issue_id) tree.write(result_xml_file)
def project_summary(self, junit_file): """To get the project name, project status and it's location""" tree = xml_Utils.get_tree_from_file(self.junit_file) for names in tree.iter('testsuites'): proj_detail = names.attrib proj_name = proj_detail.get('name') file_type = self.get_file_type(junit_file) project_status = proj_detail.get('status') proj_loc = [] for properties in tree.iter('property'): project_details = properties.attrib if project_details.get('name') == 'location': proj_loc.append(project_details.get('value')) proj_location = proj_loc[0] print_info("{0:10}{1:50}{2:10}{3:30}".format( file_type, proj_name, project_status, proj_location))
def project_summary(self, junit_file): """To get the project name, project status and it's location""" tree = xml_Utils.get_tree_from_file(self.junit_file) project_list = [] for names in tree.iter('testsuites'): proj_detail = names.attrib proj_name = proj_detail.get('name') file_type = self.get_file_type(junit_file) project_status = proj_detail.get('status') proj_loc = [] for properties in tree.iter('property'): project_details = properties.attrib if project_details.get('name') == 'location': proj_loc.append(project_details.get('value')) proj_location = proj_loc[0] project_list.append([file_type, proj_name, project_status, proj_location]) return project_list
def suite_summary(self, junit_file): """ To get the name, status and location of both test suite and test case""" tree = xml_Utils.get_tree_from_file(self.junit_file) file_type = self.get_file_type(junit_file) for values in tree.iter('testsuite'): suite_detail = values.attrib suite_name = suite_detail.get('name') suite_status = suite_detail.get('status') suite_location = suite_detail.get('suite_location') if suite_location != None: print_info("{0:10}{1:50}{2:10}{3:30}".format( "Suites", suite_name, suite_status, suite_location)) for value in tree.iter('testcase'): testcase_details = value.attrib testcase_status = testcase_details.get('status') suite_name_from_tc = testcase_details.get('classname') testcase_location = testcase_details.get('testcasefile_path') testcase_name = testcase_details.get('name') + ".xml" if suite_name == suite_name_from_tc: print_info("{0:10}{1:50}{2:10}{3:30}".format( "Testcase", testcase_name, testcase_status, testcase_location))