def bdd_common_after_scenario(context_or_world, scenario, status): """Clean method that will be executed after each scenario in behave or lettuce :param context_or_world: behave context or lettuce world :param scenario: running scenario :param status: scenario status (passed, failed or skipped) """ # Get scenario name without spaces and behave data separator scenario_file_name = scenario.name.replace(' -- @', '_').replace(' ', '_') if status == 'skipped': return elif status == 'passed': test_status = 'Pass' test_comment = None context_or_world.logger.info("The scenario '{0}' has passed".format(scenario.name)) else: test_status = 'Fail' test_comment = "The scenario '{0}' has failed".format(scenario.name) context_or_world.logger.error(test_comment) # Capture screenshot on error DriverWrappersPool.capture_screenshots(scenario_file_name) # Save webdriver logs on error or if it is enabled test_passed = status == 'passed' DriverWrappersPool.save_all_webdriver_logs(scenario.name, test_passed) # Close browser and stop driver if it must not be reused reuse_driver = context_or_world.toolium_config.getboolean_optional('Driver', 'reuse_driver') DriverWrappersPool.close_drivers_and_download_videos(scenario_file_name, test_passed, reuse_driver) # Save test status to be updated later context_or_world.global_status['test_passed'] = context_or_world.global_status[ 'test_passed'] and test_passed if reuse_driver else test_passed add_jira_status(get_jira_key_from_scenario(scenario), test_status, test_comment)
def bdd_common_after_scenario(context_or_world, scenario, status): """Clean method that will be executed after each scenario in behave or lettuce :param context_or_world: behave context or lettuce world :param scenario: running scenario :param status: scenario status (passed, failed or skipped) """ if status == 'skipped': return elif status == 'passed': test_status = 'Pass' test_comment = None context_or_world.logger.info("The scenario '%s' has passed", scenario.name) else: test_status = 'Fail' test_comment = "The scenario '%s' has failed" % scenario.name context_or_world.logger.error("The scenario '%s' has failed", scenario.name) context_or_world.global_status['test_passed'] = False # Close drivers DriverWrappersPool.close_drivers(scope='function', test_name=scenario.name, test_passed=status == 'passed', context=context_or_world) # Save test status to be updated later add_jira_status(get_jira_key_from_scenario(scenario), test_status, test_comment)
def bdd_common_after_scenario(context_or_world, scenario, status): """Clean method that will be executed after each scenario in behave or lettuce :param context_or_world: behave context or lettuce world :param scenario: running scenario :param status: scenario status (passed, failed or skipped) """ if status == 'skipped': return elif status == 'passed': test_status = 'Pass' test_comment = None context_or_world.logger.info("The scenario '%s' has passed", scenario.name) else: test_status = 'Fail' test_comment = "The scenario '%s' has failed" % scenario.name context_or_world.logger.error("The scenario '%s' has failed", scenario.name) context_or_world.global_status['test_passed'] = False # Close drivers DriverWrappersPool.close_drivers(scope='function', test_name=scenario.name, test_passed=status == 'passed', context=context_or_world) # Save test status to be updated later add_jira_status(get_jira_key_from_scenario(scenario), test_status, test_comment)
def bdd_common_after_scenario(context_or_world, scenario, status): """Clean method that will be executed after each scenario in behave or lettuce :param context_or_world: behave context or lettuce world :param scenario: running scenario :param status: scenario status (passed, failed or skipped) """ # Get scenario name without spaces and behave data separator scenario_file_name = scenario.name.replace(' -- @', '_').replace(' ', '_') if status == 'skipped': return elif status == 'passed': test_status = 'Pass' test_comment = None context_or_world.logger.info("The scenario '{0}' has passed".format( scenario.name)) else: test_status = 'Fail' test_comment = "The scenario '{0}' has failed".format(scenario.name) DriverWrappersPool.capture_screenshots(scenario_file_name) context_or_world.logger.error(test_comment) # Write Webdriver logs to files context_or_world.utils.save_all_webdriver_logs(scenario.name) # Close browser and stop driver if it must not be reused reuse_driver = context_or_world.toolium_config.getboolean_optional( 'Driver', 'reuse_driver') DriverWrappersPool.close_drivers_and_download_videos( scenario_file_name, status == 'passed', reuse_driver) # Save test status to be updated later add_jira_status(get_jira_key_from_scenario(scenario), test_status, test_comment)
def bdd_common_after_scenario(context_or_world, scenario, status): """Clean method that will be executed after each scenario in behave or lettuce :param context_or_world: behave context or lettuce world :param scenario: running scenario :param status: scenario status (passed, failed or skipped) """ # Get scenario name without spaces and behave data separator scenario_file_name = scenario.name.replace(' -- @', '_').replace(' ', '_') if status == 'skipped': return elif status == 'passed': test_status = 'Pass' test_comment = None context_or_world.logger.info("The scenario '%s' has passed", scenario.name) else: test_status = 'Fail' test_comment = "The scenario '%s' has failed" % scenario.name context_or_world.logger.error("The scenario '%s' has failed", scenario.name) # Capture screenshot on error DriverWrappersPool.capture_screenshots(scenario_file_name) # Save webdriver logs on error or if it is enabled test_passed = status == 'passed' DriverWrappersPool.save_all_webdriver_logs(scenario.name, test_passed) # Close browser and stop driver if it must not be reused restart_driver_fail = context_or_world.toolium_config.getboolean_optional( 'Driver', 'restart_driver_fail') maintain_default = context_or_world.reuse_driver and ( test_passed or not restart_driver_fail) DriverWrappersPool.close_drivers_and_download_videos( scenario_file_name, test_passed, maintain_default) # Start driver if it has been closed due to a failed test if context_or_world.reuse_driver and not test_passed and restart_driver_fail: start_driver(context_or_world) # Save test status to be updated later previous_status = context_or_world.global_status[ 'test_passed'] if context_or_world.reuse_driver else True context_or_world.global_status[ 'test_passed'] = previous_status and test_passed add_jira_status(get_jira_key_from_scenario(scenario), test_status, test_comment)