Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
def bdd_common_after_all(context_or_world):
    """Common after all method in behave or lettuce

    :param context_or_world: behave context or lettuce world
    """
    # Close drivers
    DriverWrappersPool.close_drivers(scope='session', test_name='multiple_tests',
                                     test_passed=context_or_world.global_status['test_passed'])

    # Update tests status in Jira
    change_all_jira_status()
Пример #4
0
def bdd_common_after_all(context_or_world):
    """Common after all method in behave or lettuce

    :param context_or_world: behave context or lettuce world
    """
    # Close drivers
    DriverWrappersPool.close_drivers(scope='session', test_name='multiple_tests',
                                     test_passed=context_or_world.global_status['test_passed'])

    # Update tests status in Jira
    change_all_jira_status()
Пример #5
0
def after_feature(context, feature):
    """Clean method that will be executed after each feature

    :param context: behave context
    :param feature: running feature
    """
    # Behave dynamic environment
    context.dyn_env.execute_after_feature_steps(context)

    # Close drivers
    DriverWrappersPool.close_drivers(scope='module', test_name=feature.name,
                                     test_passed=context.global_status['test_passed'])
Пример #6
0
def after_feature(context, feature):
    """Clean method that will be executed after each feature

    :param context: behave context
    :param feature: running feature
    """
    # Behave dynamic environment
    context.dyn_env.execute_after_feature_steps(context)

    # Close drivers
    DriverWrappersPool.close_drivers(scope='module', test_name=feature.name,
                                     test_passed=context.global_status['test_passed'])