Since we're using Django's StaticLiveServerTestCase internally to set everything up, we should have the ability to load our fixtures. Here's my proposal on how this will work.
In environment.py, before the call to behave-django's environment.before_scenario(), we can load our context with the fixtures array.
behave-django would then pass this on to the test case and your fixture will be loaded.
If you wanted different fixtures for different scenarios:
def before_scenario(context, scenario):
if scenario.name == 'User login with valid credentials':
context.fixtures = ['user-data.json']
elif scenario.name == 'Check out cart':
context.fixtures = ['user-data.json', 'store.json', 'cart.json']
environment.before_scenario(context, scenario)
You could also have fixtures per Feature too
def before_feature(context, feature):
if feature.name == 'Login':
context.fixtures = ['user-data.json']
# This works because behave will use the same context for everything below Feature. (Scenarios, Outlines, Backgrounds)
def before_scenario(context, scenario):
# You wouldn't need to change anything
environment.before_scenario(context, scenario)
Does this look good? Does anyone have any other suggestions?
Since we're using Django's StaticLiveServerTestCase internally to set everything up, we should have the ability to load our fixtures. Here's my proposal on how this will work.
In
environment.py
, before the call to behave-django'senvironment.before_scenario()
, we can load our context with the fixtures array.behave-django would then pass this on to the test case and your fixture will be loaded.
If you wanted different fixtures for different scenarios:
You could also have fixtures per Feature too
Does this look good? Does anyone have any other suggestions?