Allure doesn't include information appended to Scenario or Feature description in before statements
I'm submitting a ...
- [ x] bug report
- [ ] feature request
What is the current behavior?
If you include modify a Feature or Scenario description text in Behave's before_feature or before_scenario this is not reflected in the allure result.
Steps:
I've added something like this to my environment.py file
def before_feature(context, feature):
if 'server' in context.config.userdata:
feature.name += ' on ' + context.config.userdata['server'] + ' environment.'
def before_scenario(context, scenario):
if 'browser' in context.tags:
context.driver = webdriver.Chrome()
scenario.name += ' in ' + context.driver.capabilities['browserName'] + ' ' + context.driver.capabilities['version']
Then running with something like behave -D server="testing" qa/functional/features/
What is the expected behavior?
The feature should have on testing environment. added to it on the allure report. And the scenario should have something like in chrome 68.0.3440.84 appended to the end of the name. Currently the allure report includes the feature and scenario descriptions without the appended information. Behave will include this appended information if I do not run with the formatter.
What is the motivation / use case for changing the behavior?
I'm trying to edit the Scenario and feature names without using Tables.
Please tell us about your environment:
- Allure version: 2.6.0
- Test framework: behave==1.2.6
- Allure adaptor: allure-behave==2.50
Any update on above?
@sseliverstov Could you please help with above query? Really need some feature to update the scenario name.
Hi!
I was able to reproduce the issue with both a 2.5.0 and 2.12.0 (the most recent at the time) versions of allure-behave but it appeared in a slightly different way compared to the OP:
Given the following input files:
- issue279.feature
Feature: Reproduce issue 279 Scenario: Scenario to reproduce issue 279 Given Step to reproduce issue 279 - steps.py
from behave import given @given("Step to reproduce issue 279") def given_step_to_reproduce_issue_279(context): pass - environment.py
def before_feature(context, feature): feature.name = "Issue 279 not reproduced for feature" def before_scenario(context, scenario): scenario.name = "Issue 279 not reproduced for scenario" def before_step(context, step): step.name = "Issue 279 not reproduced for step"
If we run the behave with the following command:
behave -f allure_behave.formatter:AllureFormatter -f pretty -o ./.allure-results/issue279 ./features/issue279.feature
Then it will produce the following results:
- *result.json (significant fields only)
{ "name": "Scenario to reproduce issue 279", "status": "passed", "steps": [{ "name": "Given Step to reproduce issue 279", "status": "passed" }], "labels": [{ "name": "feature", "value": "Issue 279 not reproduced for feature" }] }
Looks like allure-behave picks up a name update from before_feature as expected, while ignoring one from before_scenario and before_step. I will try to fix this later.
If someone has different reproducible behavior, please, post it here.
For future contribution:
I took a look at how behave calls a formatter and environment setup functions. It is poorly documented so the best way to figure it out is to do some observations. Here is the sequence of calls I observed (being applied to allure-behave in particular):
- allure_behave.formatter.AllureFormatter.uri
environment.before_feature- allure_behave.formatter.AllureFormatter.feature
- allure_behave.listener.AllureListener.start_test <-- feature and scenario names are captured here
environment.before_scenario- allure_behave.formatter.AllureFormatter.step
- allure_behave.formatter.AllureFormatter.match <-- step name is captured here
environment.before_stepenvironment.after_step- allure_behave.formatter.AllureFormatter.result
environment.after_scenario- allure_behave.listener.AllureListener.stop_test
environment.after_feature- allure_behave.formatter.AllureFormatter.eof
- allure_behave.formatter.AllureFormatter.close_stream
Given this lifecycle, it`s no surprise that the changes are not reflected properly.
To fix that we can update the test`s name, fullName and description in allure_behave.listener.AllureListener.stop_scenario, and the step`s name in allure_behave.listener.AllureListener.stop_behave_step (by providing a new name to the stop_step call).
And probably it is better to use formatter`s scenario function instead of mangling the scenario`s run function, but that requires additional testing.
@delatrie Hi delatrie, is this bug fixed? I meet the same question in allure-behave(version:2.13.1).
@Rexze001 It's not yet fixed, sorry.
@delatrie It's okay, hope you guys can fix it soon.