嵌套示例:在黄瓜特征文件中

时间:2014-11-13 21:39:21

标签: cucumber gherkin calabash-android

以下是可能的吗?我正在使用calabash-android进行测试。

我有3种类型的用户
我想记录3中的每一个,并确保屏幕上有9个元素。

我可以嵌套3种用户类型,然后让每种用户类型查找9种元素中的每一种吗?

Feature: Overview screen on Mobile App
  In order to access all the features of the Mobile App
  As a user of the Mobile App
  I want to be able to access the features through the Overview Screen

  @high
  Scenario Outline: Overview Screen Appearance
    Given I login to an <type> account

    Examples:
      | type          |
      | secure        |
      | user          |
      | admin         |

    Then I should see the <element>

    Examples:
      | element                     |
      | Overview Header             |
      | Status Icon                 |
      | Status Text                 |
      | Status Time                 |
      | Current Temp Icon           |
      | Navigation Overview Text    |
      | Navigation Overview Icon    |
      | Navigation Activity Text    |
      | Navigation Activity Icon    |

由于

2 个答案:

答案 0 :(得分:2)

这听起来更像是使用数据表的任务。然后,实现该步骤的代码将检查数据表参数的每个元素是否存在于页面上。

Scenario Outline: Overview Screen Appearance
  Given I login to an <type> account
  Then I should see the following elements:
    | element                     |
    | Overview Header             |
    | Status Icon                 |
    | Status Text                 |
    | Status Time                 |
    | Current Temp Icon           |
    | Navigation Overview Text    |
    | Navigation Overview Icon    |
    | Navigation Activity Text    |
    | Navigation Activity Icon    |
  Examples:
    | type          |
    | secure        |
    | user          |
    | admin         |

答案 1 :(得分:0)

您也可以考虑使用FactoryGirl。

如果你有复杂的数据模型,你可以简单地以工厂的形式抽象出来,而不是制作复杂的静态特征文件。