Search code examples
cucumbergherkincalabash-android

Nested Examples: in a Cucumber Feature File


Is something like the following possible? I am testing using calabash-android.

I have 3 types of users
I want to log each of the 3 in and make sure the screen has each of the 9 elements.

Can I nest the 3 user types and then have each user type look for each of the 9 elements?

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    |

Thanks


Solution

  • That sounds more like a task for using a datatable. The code implementing the step would then check that each element of the datatable parameter is present on the page.

    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         |