0

I have Scenario outline with multiple examples looking something like this:

 Examples:
|    country      |     type      |    number   |
| Poland          | An individual |      -      |
| Poland          | Company       | 8971660890  |
| Germany         | An individual |      -      |
| France          | Company       | 92511490856 |

I want to use this examples and pass it to one of step definitions in order to create conditional expressions, for example:

@step(check_sth)
def step_imp(country, type, number):
if county == Poland:
   do sth
elif type == individual:
   do other thing

is it possible in bahave?

Ewa
  • 65
  • 3
  • 11

1 Answers1

1

See the behave tutorial for how to do this: https://pythonhosted.org/behave/tutorial.html

In particular, have a look at how to set-up Scenario Outlines, e.g:

    Given I enter the following data <country> <type> and <number>,
    Then  check that <country> is correct

would give you the following step definition:

    @given('I enter the following data "{country}" "{type}" and "{number}",')
    def step_impl(context, country, type, number):

    @then('check that "{country}" is correct')
    def step_impl(context, country):
Andreas
  • 221
  • 1
  • 11
  • But can I use country, type and number in different step? I have steps: '"{type}" is chosen' and "{country}" is selected' and I want to use country and type in another step. – Ewa Oct 10 '17 at 11:06
  • Yes, you can reuse them in the same scenario. Simply define another step using the same parameters. – Andreas Oct 10 '17 at 11:26