0

环境:lettuce-0.2.23-py2.7对于Windows 8
简单的场景(来自 Lettuce 文档的示例)一切正常:

@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'))

但我不知道如何通过Scenario Outline像这样的乘法示例

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

将其粘贴到父场景中:

@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()

堆栈跟踪:

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:

看起来我需要搞乱在lettuce-0.2.23-py2.7.egg!\lettuce\core.py哪里behave_as实现方法来识别轮廓。
其他解决方案是将for loop步骤与examples作为集合来实现。有什么建议吗?

4

1 回答 1

0

当然,这里有一个片段:

@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))
于 2014-12-09T09:24:22.167 回答