You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
allure-behave: extend scenario_history_id to use optional environment variable #880
allure-behave: extend scenario_history_id to use optional environment variable
We have a problem where we want to run the same test-suite in different environments. For example:
Execute Test-Suite for Different Browser: Firefox, Chrome, ... (i.e. 'BROWSER=firefox behave' 'BROWSER=chromium behave' etc.)
Execute Test-Suite for Different Systems: Linux armx64, Linux amd64, Win amd64, ...
If we collect all JSON allure-results and generate an allure report we only see one result for each test-scenario. Other executions are shown only in the "retries" section. We need to change the history ID so that each execution appears as a separate test.
We want to solve this by adding additional information into the historyId. It would have been nice to use additional user-modifiable information from the Scenario object, but this is not possible since scenario_history_id() is called before the before_scenario() hook (environment.py). Therefore not action in the before_scenario hook function (like changing scenario name or adding other information, can impact the historyId.
Thus, we designed a solution that uses an environment variable to pass this information. Our proposal is to the set an environment variable in environment.py that is used to influence the historyId.
In allure-python/allure-behave/src/utils.py:
defscenario_history_id(scenario) ->str:
""" Create a historyId for a scenario. - Always based on feature name and scenario name - Optional: can append a value from an environment variable """parts= [scenario.feature.name, scenario.name]
ifhasattr(scenario, "_row") andscenario._row:
row=scenario._rowparts.extend([f"{name}={value}"forname, valueinzip(row.headings, row.cells)])
# Optional: append environment variable to differentiate runshistory_id=os.getenv("ALLURE_HISTORY_ID")
ifhistory_id:
parts.append(history_id)
returnmd5(*parts)
To use this feature, add the environment variable in environment.py:
Activity