In Python's behave library, I can write a feature file with a parametrised Scenario Outline like so (adapted from this tutorial):
# feature file
Feature: Scenario Outline Example
Scenario Outline: Use Blender with <thing>
Given I put "<thing>" in a blender
When I switch the blender on
Then it should transform into "<other thing>"
Examples: Amphibians
| thing | other thing |
| Red Tree Frog | mush |
| apples | apple juice |
The according step definitions would look like this:
# steps file
from behave import given, when, then
from hamcrest import assert_that, equal_to
from blender import Blender
@given('I put "{thing}" in a blender')
def step_given_put_thing_into_blender(context, thing):
context.blender = Blender()
context.blender.add(thing)
@when('I switch the blender on')
def step_when_switch_blender_on(context):
context.blender.switch_on()
@then('it should transform into "{other_thing}"')
def step_then_should_transform_into(context, other_thing):
assert_that(context.blender.result, equal_to(other_thing))
As one can see, the way to pass the parameters from the feature file into the step functions is
- by explicitly mentioning them in the feature file enclosed in angle brackets
- then include the same words enclosed in curly brackets (why not angle brackets again?!) in the decorator of the step function
- and finally insert these words as function arguments of the step function.
However, given a larger example table with a lot of columns, this quickly gets annoying to write and read:
# feature file
Feature: Large Table Example
Scenario Outline: Use Blender with a lot of things
Given I put "<first_thing>", "<second_thing>", "<third_thing>", "<fourth_thing>", "<fifth_thing>", "<sixth_thing>", "<seventh_thing>" in a blender
When I switch the blender on
Then it should transform into "<other thing>"
Examples: Things
| first thing | second thing | third thing | fourth thing | fifth thing | sixth thing | seventh thing |
| a | b | c | d | e | f | g | h |
| i | j | k | l | m | n | o | p |
# steps file
@given('I put "{first_thing}", "{second_thing}", "{third_thing}", "{fourth_thing}", "{fifth_thing}", "{sixth_thing}", "{seventh_thing}", in a blender')
def step_given_put_thing_into_blender(context, first_thing, second_thing, third_thing, fourth_thing, fifth_thing, sixth_thing, seventh_thing):
context.blender = Blender()
context.blender.add(thing)
...
I think the point is clear. Is there any possibility to transfer the examples from a large table into the step definition without having to mention all of them explicitly? Are they, for instance, saved somewhere in the context variable even without mentioning them in the text (could not find them there yet)?