hrcorval / behavex

BDD testing solution designed to enhance your Behave-based testing workflows
https://github.com/hrcorval/behavex
MIT License
89 stars 20 forks source link

runner: create_scenario_line_references() -- Scenario detection does not work for Non-English languages #77

Closed jenisys closed 1 year ago

jenisys commented 1 year ago

Describe the bug Scenario versus ScenarioOutline detection logic in behave/runner.py is extremely brittle because it relies on English keyword "Scenario". This solution will not work in other languages except in English. In addition, by now Gherkin supports multiple aliases for Scenario (even in English language). Therefore, it is better to check is-instance-of(Scenario) instead of checking the keyword, like:

# -- FILE: behavex/runner.py
from behave.model import ScenarioOutline   # ADDED
...
def create_scenario_line_references(features):
    ...
    for feature in features:
        ...
        for scenario in feature.scenarios:
            # ORIG: if scenario.keyword == u'Scenario':  # -- PROBLEM-POINT was here
            if not isinstance(scenario, ScenarioOutline):  # NEW_SOLUTION_HERE
                feature_lines[scenario.name] = scenario.line
            else:
                ...

To Reproduce Steps to reproduce the behavior:

  1. Run behavex features against the behave/tools/test-features/french.feature (using keyword: Scénario (with accept)
  File "/.../behavex/runner.py", line 2xx, in create_scenario_line_references
    for scenario_multiline in scenario.scenarios:
AttributeError: 'Scenario' object has no attribute 'scenarios'

Expected behavior Scenario detection logic should be independent of keywords and should work for any language.

Version Info:

anibalinn commented 1 year ago

Fix implemented in the upcoming release branch release_2.0.2

anibalinn commented 1 year ago

Fix released in version 3.0.0: https://pypi.org/project/behavex/3.0.0/ branch release_3.0.0 Thanks!