0

Environment: lettuce-0.2.23-py2.7 on Windows 8
For simple scenario (example from Lettuce documentation) everything works:

@step('I am logged in')
def is_logged_in(step):
    step.behave_as("""
        Given I go to the home page
          And I click the login button
          And I fill in username:{user} password:{pass}
          And I click "Login"
    """.format(user='floppy', pass='banana'))

But I don't know how to pass Scenario Outline with multiply examples like

Given cat with name "<cat_name>"
Examples:
  |cat_name|
  |filemon |
  |tomcat  |

Pasting it in parent scenario:

@step('I have bunch of cats')
    def bunch_of_cats(step):
        step.behave_as("""
            Given cat with name "<cat_name>"
               Examples:
                |cat_name|
                |filemon |
                |tomcat  |
        """.format()

StackTrace:

Traceback (most recent call last):
  File "build\bdist.win-amd64\egg\lettuce\core.py", line 144, in __call__
    ret = self.function(self.step, *args, **kw)
  File "\\features\steps\manager_steps.py", line 590, in magic
    """.format())
  File "build\bdist.win-amd64\egg\lettuce\core.py", line 408, in behave_as
    assert not steps_undefined, "Undefined step: %s" % steps_undefined[0].sentence
AssertionError: Undefined step: Examples:

Looks like I need to mess with lettuce-0.2.23-py2.7.egg!\lettuce\core.py where behave_as method is implemented to recognise outlines.
Other solution is to implement for loop for step with examples as a collection. Any advice?

pbaranski
  • 22,778
  • 19
  • 100
  • 117

1 Answers1

0

Sure, here's a snippet:

@step("Given cat with name (\w+)")
def set_cat_name(step, name):
    step.behave_as("""
        Given another step that requires a name of a cat {0}
    """.format(name))
Tomasz Wszelaki
  • 652
  • 4
  • 2
  • I'm looking for answer: how to run full scenario outline (http://lettuce.it/tutorial/scenario-outlines.html) in behave.as section - updated question should show it better. – pbaranski Dec 12 '14 at 09:13
  • I don't think that's possible. What are you trying to do? Set up some data before running tests? – Tomasz Wszelaki Dec 15 '14 at 08:21
  • I need to run long scenario as Then step (@after has no use since different Then in scenarios in feature) – pbaranski Dec 15 '14 at 10:12
  • Could you post the full content of your .feature file and tell me which steps you wish to run in the `behave_as` step? Maybe then I could help you more. – Tomasz Wszelaki Dec 15 '14 at 11:50