From 64fb22734d5606f4cb61756a9f77d34d780ecc20 Mon Sep 17 00:00:00 2001 From: anibalinn Date: Fri, 27 Dec 2024 12:53:20 -0300 Subject: [PATCH] Adding scenarios to validate the rerun command works properly --- behavex/utils.py | 11 ++++++++--- tests/features/failing_scenarios.txt | 1 + tests/features/rerun_scenarios.feature | 19 +++++++++++++++++++ tests/features/steps/execution_steps.py | 7 +++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 tests/features/failing_scenarios.txt create mode 100644 tests/features/rerun_scenarios.feature diff --git a/behavex/utils.py b/behavex/utils.py index 32af33d..f44cfeb 100644 --- a/behavex/utils.py +++ b/behavex/utils.py @@ -178,7 +178,6 @@ def join_scenario_reports(json_reports): def explore_features(features_path, features_list=None): if features_list is None: features_list = [] - # Normalize path separators pure_feature_path, scenario_line = get_feature_and_scenario_line(features_path) normalized_features_path = os.path.normpath(pure_feature_path) @@ -190,8 +189,14 @@ def explore_features(features_path, features_list=None): if scenario_line: # iterate over scenarios and add the scenario that matches the scenario line for scenario in feature.scenarios: - if scenario.line == int(scenario_line): - features_list.append(scenario) + #check if scenario is a ScenarioOutline + if isinstance(scenario, ScenarioOutline): + for example in scenario.scenarios: + if example.line == int(scenario_line): + features_list.append(example) + else: + if scenario.line == int(scenario_line): + features_list.append(scenario) else: features_list.extend(feature.scenarios) else: diff --git a/tests/features/failing_scenarios.txt b/tests/features/failing_scenarios.txt new file mode 100644 index 0000000..84f4c71 --- /dev/null +++ b/tests/features/failing_scenarios.txt @@ -0,0 +1 @@ +tests/features/secondary_features/passing_tests.feature:8,tests/features/secondary_features/passing_tests.feature:29,tests/features/secondary_features/failing_tests.feature:3 diff --git a/tests/features/rerun_scenarios.feature b/tests/features/rerun_scenarios.feature new file mode 100644 index 0000000..7006c3a --- /dev/null +++ b/tests/features/rerun_scenarios.feature @@ -0,0 +1,19 @@ +Feature: Failing Scenarios + + @FAILING + Scenario Outline: Performing rerun of failing scenarios using the -rf option + Given I have installed behavex + When I setup the behavex command with "" parallel processes and parallel scheme set as "" + When I run the behavex command with a file of failing tests + Then I should see the following behavex console outputs and exit code "1" + | output_line | + | 2 scenarios passed, 1 failed | + | Exit code: 1 | + And I should not see exception messages in the output + And I should see the same number of scenarios in the reports not considering the skipped scenarios + And I should see the generated HTML report does not contain internal BehaveX variables and tags + Examples: + | parallel_scheme | parallel_processes | + | scenario | 1 | + | scenario | 3 | + | feature | 2 | diff --git a/tests/features/steps/execution_steps.py b/tests/features/steps/execution_steps.py index a1a8d0f..5945d42 100644 --- a/tests/features/steps/execution_steps.py +++ b/tests/features/steps/execution_steps.py @@ -23,6 +23,13 @@ def step_impl(context): execute_command(context, execution_args) +@when('I run the behavex command with a file of failing tests') +def step_impl(context): + context.output_path = os.path.join('output', 'output_{}'.format(get_random_number(6))) + execution_args = ['behavex', '-rf', os.path.join(tests_features_path, 'failing_scenarios.txt'), '-o', context.output_path] + execute_command(context, execution_args) + + @when('I run the behavex command that renames scenarios and features') def step_impl(context): context.output_path = os.path.join('output', 'output_{}'.format(get_random_number(6)))