I am using behave fixtures to create a counter during test run. I initialize the counter in before_all
hook, and later increment it in before_scenario
every time a scenario is running.
I thought before_all
runs once during the entire test, and if a variable is added to the context it is available for later.
Here I am initializing context.i = 0
in before_all
, but in before_scenario
every time a scenario is run, the value of context.i
is again set to 0.
environment.py
def before_all(context):
context.i = 0
def before_scenario(context, scenario):
context.i = context.i + 1
I want to increment i
with every run. But it is always set to 1
.