Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Context
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:
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.pythat is used to influence thehistoryId.In
allure-python/allure-behave/src/utils.py:To use this feature, add the environment variable in
environment.py: