【问题标题】:"Feature Background" or "Feature Steps" in lettuce?生菜中的“特征背景”或“特征步骤”?
【发布时间】:2013-10-07 10:48:18
【问题描述】:

我正在lettuce 中寻找一种方法来指定要从我的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

所以我已经为预先设定的示例列表工作,并且我已经能够通过使用挂钩来扩展场景来测试逻辑,并且它可以工作,但这意味着如果一个功能失败了那些将是 after 不会运行。

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

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

【问题讨论】:

    标签: python bdd lettuce


    【解决方案1】:

    目前作为折衷方案,我想出了这个:

    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 标签,我已经存储了一个要运行的回调。这似乎仍然不理想,但我将其发布给任何试图解决相同问题的人,直到找到更好的解决方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-12
      • 2013-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多