Skip to content

Commit

Permalink
Add Background integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
timofurrer committed Nov 10, 2019
1 parent 5151233 commit 47b89ad
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions tests/integration/features/Background.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Feature: Support a Feature Background
In order to be Gherkin compatible
radish supports the Background block
in a Feature.

Scenario: A Background is ran before a Scenario
Given the Feature File "background.feature"
"""
Feature: Some Feature
Background:
Given the setup is done
Scenario: a fancy Example
Then the setup has been done
"""
And the base dir module "steps.py"
"""
from radish import given, then
@given("the setup is done")
def do_setup(step):
step.context.setup = True
@then("the setup has been done")
def expect_setup_done(step):
assert step.context.setup
"""
When the "background.feature" is run
Then the exit code should be 0

Scenario: The Scenario Hook is run before the Background Steps
Given the Feature File "background.feature"
"""
Feature: Some Feature
Background:
Given the setup is done
Scenario: a fancy Example
Then the setup has been done
"""
And the base dir module "steps.py"
"""
from radish import given, then, before
@before.each_scenario()
def before_scenario(scenario):
scenario.context.setup = None
@given("the setup is done")
def do_setup(step):
assert step.context.setup is None
step.context.setup = True
@then("the setup has been done")
def expect_setup_done(step):
assert step.context.setup
"""
When the "background.feature" is run
Then the exit code should be 0

Scenario: Each Scenario has it's own copy of the Background
Given the Feature File "background.feature"
"""
Feature: Some Feature
Background:
Given the setup is done
Scenario: First Scenario
Then the setup has been done
Scenario: Second Scenario
"""
And the base dir module "steps.py"
"""
from radish import given, then
@given("the setup is done")
def do_setup(step):
assert not hasattr(step.context, "setup")
step.context.setup = True
@then("the setup has been done")
def expect_setup_done(step):
assert step.context.setup
"""
When the "background.feature" is run
Then the exit code should be 0

0 comments on commit 47b89ad

Please sign in to comment.