def _skip_because_of_goto(self): """ This function would skip step because of goto """ keyword = self.current_step.get('Keyword') kw_resultfile = step_driver.get_keyword_resultfile(self.data_repository, self.system_name, self.current_step_number, keyword) Utils.config_Utils.set_resultfile(kw_resultfile) Utils.testcase_Utils.pKeyword(keyword, self.current_step.get('Driver')) Utils.testcase_Utils.reportStatus('Skip') step_description = Utils.testcase_Utils.get_description_from_xmlfile(self.current_step) self.kw_resultfile_list.append(kw_resultfile) self.data_repository['wt_junit_object'].update_count("skipped", "1", "tc", self.data_repository['wt_tc_timestamp']) self.data_repository['wt_junit_object'].update_count("keywords", "1", "tc", self.data_repository['wt_tc_timestamp']) kw_start_time = Utils.datetime_utils.get_current_timestamp() step_impact = Utils.testcase_Utils.get_impact_from_xmlfile(self.current_step) impact_dict = {"IMPACT": "Impact", "NOIMPACT": "No Impact"} self.data_repository['wt_junit_object']. \ add_keyword_result(self.data_repository['wt_tc_timestamp'], self.current_step_number, keyword, "SKIPPED", kw_start_time, "0", "skipped", impact_dict.get(step_impact.upper()), "N/A", step_description) self.data_repository['step_{}_result'.format(self.current_step_number)] = "SKIPPED" return self.current_step_number, self.go_to_step_number, "continue"
def _report_step_as_not_run(self): """ This function handles reporting of a step as not run. """ keyword = self.current_step.get('Keyword') kw_resultfile = step_driver.get_keyword_resultfile( self.data_repository, self.system_name, self.current_step_number, keyword) Utils.config_Utils.set_resultfile(kw_resultfile) Utils.testcase_Utils.pKeyword(keyword, self.current_step.get('Driver')) Utils.testcase_Utils.reportStatus('Skip') self.kw_resultfile_list.append(kw_resultfile) self.data_repository['wt_junit_object'].update_count( "skipped", "1", "tc", self.data_repository['wt_tc_timestamp']) self.data_repository['wt_junit_object'].update_count( "keywords", "1", "tc", self.data_repository['wt_tc_timestamp']) kw_start_time = Utils.datetime_utils.get_current_timestamp() step_impact = Utils.testcase_Utils.get_impact_from_xmlfile( self.current_step) impact_dict = {"IMPACT": "Impact", "NOIMPACT": "No Impact"} self.data_repository['wt_junit_object'].add_keyword_result( self.data_repository['wt_tc_timestamp'], self.current_step_number, keyword, "SKIPPED", kw_start_time, "0", "skipped", impact_dict.get(step_impact.upper()), "N/A") self.data_repository['step_{}_result'.format( self.current_step_number)] = "SKIPPED" self.go_to_step_number = False if self.current_triggered_action.upper() in [ 'ABORT', 'ABORT_AS_ERROR' ]: return self.current_step_number, self.go_to_step_number, "break" elif self.current_triggered_action.upper() in ['SKIP', 'NEXT']: return self.current_step_number, self.go_to_step_number, "continue" elif self.current_triggered_action == "SKIP_INVOKED": if self.skip_invoked: print_info("Skipping this step as it is an invoked step.") return self.current_step_number, self.go_to_step_number, "continue" # when 'onError:goto' value is less than the current step num, # change the next iteration point to goto value elif self.current_triggered_action and int(self.current_triggered_action) < \ self.current_step_number: self.current_step_number = int(self.current_triggered_action) - 1 return self.current_step_number, self.go_to_step_number, "continue"
def _update_skip_results(self, step, system_name, step_num): """ """ keyword = step.get('Keyword') kw_resultfile = step_driver.get_keyword_resultfile( self.data_repository, system_name, step_num, keyword) config_Utils.set_resultfile(kw_resultfile) testcase_Utils.pKeyword(keyword, step.get('Driver')) testcase_Utils.reportStatus('Skip') print_info("\n-----------------------------------------------------\n") self.data_repository['wt_junit_object'].update_count( "skipped", "1", "tc", self.data_repository['wt_tc_timestamp']) self.data_repository['wt_junit_object'].update_count( "keywords", "1", "tc", self.data_repository['wt_tc_timestamp']) self.data_repository['wt_junit_object'].add_keyword_result( self.data_repository['wt_tc_timestamp'], step_num, keyword, "SKIPPED", "skipped", "skipped", "skipped", "skipped", "skipped") result = ("Skip", kw_resultfile, None, None) return result
def _skip_because_of_goto(self): """ This function would skip step because of goto """ keyword = self.current_step.get('Keyword') kw_resultfile = step_driver.get_keyword_resultfile( self.data_repository, self.system_name, self.current_step_number, keyword) Utils.config_Utils.set_resultfile(kw_resultfile) Utils.testcase_Utils.pKeyword(keyword, self.current_step.get('Driver')) Utils.testcase_Utils.reportStatus('Skip') step_description = Utils.testcase_Utils.get_description_from_xmlfile( self.current_step) self.kw_resultfile_list.append(kw_resultfile) self.data_repository['wt_junit_object'].update_count( "skipped", "1", "tc", self.data_repository['wt_tc_timestamp']) self.data_repository['wt_junit_object'].update_count( "keywords", "1", "tc", self.data_repository['wt_tc_timestamp']) kw_start_time = Utils.datetime_utils.get_current_timestamp() step_impact = Utils.testcase_Utils.get_impact_from_xmlfile( self.current_step) impact_dict = {"IMPACT": "Impact", "NOIMPACT": "No Impact"} self.data_repository['wt_junit_object']. \ add_keyword_result(self.data_repository['wt_tc_timestamp'], self.current_step_number, keyword, "SKIPPED", kw_start_time, "0", "skipped", impact_dict.get(step_impact.upper()), "N/A", step_description) self.data_repository['step_{}_result'.format( self.current_step_number)] = "SKIPPED" # print the end of runmode execution as the steps skip when the condition # is met for RUF/RUP if self.current_step.find("runmode") is not None and \ self.current_step.find("runmode").get("attempt") is not None: if self.current_step.find("runmode").get("attempt") == \ self.current_step.find("runmode").get("runmode_val"): print_info( "\n----------------- End of Step Runmode Execution -----------------\n" ) return self.current_step_number, self.go_to_step_number, "continue"
kw_resultfile = result[1] step_impact = result[2] exec_type_onerror = result[3] # print "exec_type_onerror:", exec_type_onerror except Exception,e: print_error('unexpected error %s' % str(e)) step_status = False kw_resultfile = None step_impact = Utils.testcase_Utils.get_impact_from_xmlfile(step) print_error('unexpected error {0}'.format(traceback.format_exc())) goto_stepnum = False else: keyword = step.get('Keyword') kw_resultfile = step_driver.get_keyword_resultfile(data_repository, system_name, step_num, keyword) Utils.config_Utils.set_resultfile(kw_resultfile) Utils.testcase_Utils.pKeyword(keyword, step.get('Driver')) Utils.testcase_Utils.reportStatus('Skip') step_description = Utils.testcase_Utils.get_description_from_xmlfile(step) kw_resultfile_list.append(kw_resultfile) data_repository['wt_junit_object'].update_count("skipped", "1", "tc", data_repository['wt_tc_timestamp']) data_repository['wt_junit_object'].update_count("keywords", "1", "tc", data_repository['wt_tc_timestamp']) kw_start_time = Utils.datetime_utils.get_current_timestamp() step_impact = Utils.testcase_Utils.get_impact_from_xmlfile(step) impact_dict = {"IMPACT": "Impact", "NOIMPACT": "No Impact"} data_repository['wt_junit_object'].\ add_keyword_result(data_repository['wt_tc_timestamp'], step_num, keyword, "SKIPPED", kw_start_time, "0", "skipped",
def execute_steps(step_list, data_repository, system_name, parallel, queue): """ Take in a list of steps iterate through each of them and decide if each should run (pre-run check) get status and report to term and log """ default_error_action = data_repository['wt_def_on_error_action'] default_error_value = data_repository['wt_def_on_error_value'] goto_stepnum = False kw_resultfile_list = [] step_status_list = [] step_impact_list = [] step_num = 0 if parallel is True: system_console_log = get_system_console_log( data_repository['wt_filename'], data_repository['wt_logsdir'], '{0}_consoleLogs'.format(system_name)) while step_num < len(step_list): step = step_list[step_num] # execute steps step_num += 1 run_current_step = False # Decide whether or not to execute keyword # First decide if this step should be executed in this iteration if not goto_stepnum or goto_stepnum == str(step_num): # get Exectype information run_current_step, trigger_action = exec_type_driver.main(step) if not run_current_step: keyword = step.get('Keyword') kw_resultfile = step_driver.get_keyword_resultfile( data_repository, system_name, step_num, keyword) Utils.config_Utils.set_resultfile(kw_resultfile) Utils.testcase_Utils.pKeyword(keyword, step.get('Driver')) Utils.testcase_Utils.reportStatus('Skip') kw_resultfile_list.append(kw_resultfile) data_repository['wt_junit_object'].update_count( "skipped", "1", "tc", data_repository['wt_tc_timestamp']) data_repository['wt_junit_object'].update_count( "keywords", "1", "tc", data_repository['wt_tc_timestamp']) kw_start_time = Utils.datetime_utils.get_current_timestamp() step_impact = Utils.testcase_Utils.get_impact_from_xmlfile( step) impact_dict = {"IMPACT": "Impact", "NOIMPACT": "No Impact"} data_repository['wt_junit_object'].add_keyword_result( data_repository['wt_tc_timestamp'], step_num, keyword, "SKIPPED", kw_start_time, "0", "skipped", impact_dict.get(step_impact.upper()), "N/A") data_repository['step_{}_result'.format(step_num)] = "SKIPPED" if trigger_action.upper() in ['ABORT', 'ABORT_AS_ERROR']: break elif trigger_action.upper() in ['SKIP', 'NEXT']: continue # when 'onError:goto' value is less than the current step num, # change the next iteration point to goto value elif trigger_action and int(trigger_action) < step_num: step_num = int(trigger_action) - 1 trigger_action = False continue if not goto_stepnum: try: result = step_driver.main(step, step_num, data_repository, system_name) step_status = result[0] kw_resultfile = result[1] step_impact = result[2] except Exception, e: print_error('unexpected error %s' % str(e)) step_status = False kw_resultfile = None step_impact = Utils.testcase_Utils.get_impact_from_xmlfile( step) print_error('unexpected error {0}'.format( traceback.format_exc())) elif goto_stepnum and goto_stepnum == str(step_num): try: result = step_driver.main(step, step_num, data_repository, system_name) step_status = result[0] kw_resultfile = result[1] step_impact = result[2] except Exception, e: print_error('unexpected error %s' % str(e)) step_status = False kw_resultfile = None step_impact = Utils.testcase_Utils.get_impact_from_xmlfile( step) print_error('unexpected error {0}'.format( traceback.format_exc()))