0

我正在寻找一种在生菜中指定要从我的Gherkin功能文件运行的代码的方法,以便在我到达钩子时它已经运行@before.each_scenario- 这本质上是为场景大纲做一组动态示例,所以给定一个具有事物目录的应用程序,我想测试每个事物,我希望能够执行以下操作:

Feature: Automated Catalogue Test
    In order to have use the system
    As a user
    I want to be able to use each feature in the catalogue

    Background:
      Given I start the system
        And I have a list of features

    @foreach
    Scenario Outline: I use each feature in the system
      Given feature <feature_num>
       When I load the feature
        And I use the feature in the way they are all used
       Then I can clear up the feature

因此,我将其用于预先设置的示例列表,并且我已经能够仅通过使用挂钩来扩展场景来测试逻辑,并且它可以工作,但这意味着如果一个功能失败,那么之后的功能将失败不会运行。

如果后台步骤只运行一次,那么我可以将枚举@before.each_scenario的列表设置为,但是据我所知,这不是 Gherkin 语言的一部分;尽管有许多其他测试不需要了解此目录,但我不想添加到地形中...outlineslettuce/core.py:722I have a list of features

我想没有人有任何建议吗?

4

1 回答 1

0

目前作为妥协,我提出了这个:

Feature: Automated Catalogue Test
    In order to have use the system
    As a user
    I want to be able to use each feature in the catalogue

    @foreach @foreach_feature
    Scenario Outline: I use each feature in the system
      Given feature <feature_num>
       When I load the feature
        And I use the feature in the way they are all used
       Then I can clear up the feature

然后,在我实现了@foreach查找标签的钩子的地方,我向标签注册表添加了一个查找,我在其中存储了一个回调,如果你找到了该@foreach_feature标签就运行。这似乎仍然不理想,但我将它放在那里以供任何试图解决相同问题的人使用,直到找到更好的解决方案。

于 2013-10-07T11:18:54.643 回答