JBehave
  1. JBehave
  2. JBEHAVE-488

Scenario with nested or recursive example table

    Details

    • Type: New Feature New Feature
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      We have a UI functionality that repeats on many pages (say it is a JSPF component that is reusable, with configurable variation). But it is important to test this on all pages since the functionality is slightly different on each of these pages.

      How we have to code this today:

      Scenario: Food widget in Home page

      Given I am on Home page
      When I enter <food_item> in the menu field
      Then I see <related_food_items> in the dropdown

      Examples:

      food_item related_food_items
      pizza "cheese, chicken, bacon"
      fruit_salad "mangoes, strawberry, grapes"
      rice "brown, white, fried"

      The exact same test will repeat on a different page like below

      Scenario: Food widget in OrderFood page

      Given I am on OrderFood page
      When I enter <food_item> in the menu field
      Then I see <related_food_items> in the dropdown

      Examples:

      food_item related_food_items
      pizza "cheese, chicken, bacon"
      fruit_salad "mangoes, strawberry, grapes"
      rice "brown, white, fried"

      Problem Statement: We want to run a particular scenario with 'examples' over another parametrized value (e.g 'Page' here).

      Proposed solution: foreach meta-tag at scenario level that has processing implications.

      Scenario:

      Meta:

      @foreach Page: Home, OrderFood, CheckStatus, CancelOrder

      Given I am on the <Page> page
      When I enter <food_item> in the menu field
      Then I see <related_food_items> in the dropdown

      Examples:

      food_item related_food_items
      pizza "cheese, chicken, bacon"
      fruit_salad "mangoes, strawberry, grapes"
      rice "brown, white, fried"

        Activity

        Paul Hammant made changes -
        Field Original Value New Value
        Description We have a UI functionality that repeats on many pages. But it is important to test this on all pages since the functionality is slightly different on each of these pages.

        For eg.

        Scenario:

        Given I am on Home page
        When I enter <food_item> in the menu field
        Then I see <related_food_items> in the dropdown

        Examples:
        |food_item|related_food_items|
        |pizza|"cheese, chicken, bacon"|
        |fruit_salad|"mangoes, strawberry, grapes"|
        |rice|"brown, white, fried"|

        The exact same test will repeat on a different page like below


        Scenario:

        Given I am on OrderFood page
        When I enter <food_item> in the menu field
        Then I see <related_food_items> in the dropdown

        Examples:
        |food_item|related_food_items|
        |pizza|"cheese, chicken, bacon"|
        |fruit_salad|"mangoes, strawberry, grapes"|
        |rice|"brown, white, fried"|


        h2. Problem Statement: We want to run a particular test with examples over another parametrized value (e.g 'Page' here).

        h2. Proposed solution

        Scenario:

        Meta:

        @foreach Page: Home, OrderFood, CheckStatus, CancelOrder

        Given I am on the Page page
        When I enter <food_item> in the menu field
        Then I see <related_food_items> in the dropdown

        Examples:
        |food_item|related_food_items|
        |pizza|"cheese, chicken, bacon"|
        |fruit_salad|"mangoes, strawberry, grapes"|
        |rice|"brown, white, fried"|
        We have a UI functionality that repeats on many pages (say it is a JSPF component that is reusable, with configurable variation). But it is important to test this on all pages since the functionality is slightly different on each of these pages.

        h2. How we have to code this today:

        Scenario: Food widget in Home page

        Given I am on Home page
        When I enter <food_item> in the menu field
        Then I see <related_food_items> in the dropdown

        Examples:
        |food_item|related_food_items|
        |pizza|"cheese, chicken, bacon"|
        |fruit_salad|"mangoes, strawberry, grapes"|
        |rice|"brown, white, fried"|

        The exact same test will repeat on a different page like below


        Scenario: Food widget in OrderFood page

        Given I am on OrderFood page
        When I enter <food_item> in the menu field
        Then I see <related_food_items> in the dropdown

        Examples:
        |food_item|related_food_items|
        |pizza|"cheese, chicken, bacon"|
        |fruit_salad|"mangoes, strawberry, grapes"|
        |rice|"brown, white, fried"|


        h2. Problem Statement: We want to run a particular scenario with 'examples' over another parametrized value (e.g 'Page' here).

        h2. Proposed solution: foreach meta-tag at scenario level that has processing implications.

        Scenario:

        Meta:

        @foreach Page: Home, OrderFood, CheckStatus, CancelOrder

        Given I am on the <Page> page
        When I enter <food_item> in the menu field
        Then I see <related_food_items> in the dropdown

        Examples:
        |food_item|related_food_items|
        |pizza|"cheese, chicken, bacon"|
        |fruit_salad|"mangoes, strawberry, grapes"|
        |rice|"brown, white, fried"|
        Hide
        Mauro Talevi added a comment -

        This sounds like an interesting use case, but I would not use a meta property to drive it. Rather, we could enhance the Examples: syntax. E.g.

        Examples:

        {foreach Page: Home, OrderFood, CheckStatus, CancelOrder}

        ... table as usual

        The advantage is that we keep the parameters of the examples self-contained in the ExamplesTable (which can parse the directives too)

        Show
        Mauro Talevi added a comment - This sounds like an interesting use case, but I would not use a meta property to drive it. Rather, we could enhance the Examples: syntax. E.g. Examples: {foreach Page: Home, OrderFood, CheckStatus, CancelOrder} ... table as usual The advantage is that we keep the parameters of the examples self-contained in the ExamplesTable (which can parse the directives too)
        Hide
        kk sure added a comment -

        Hmm. Looks like a good solution.

        Show
        kk sure added a comment - Hmm. Looks like a good solution.
        Hide
        Diego Rivera added a comment -

        Wouldn't this be solved by using GivenStories and parametrisation of them using Examples and #

        {row}

        ?

        If not, then perhaps this might be an even more elegant solution: define parameters via that mechanism that are inherited onto "included" stories, and supersede the values used therein. Thus, when an example for GivenStories sets the value for <foo> to X, then the same value of <foo> will be used in the matching story, overriding any "local" definition of <foo>.

        Make sense?

        Show
        Diego Rivera added a comment - Wouldn't this be solved by using GivenStories and parametrisation of them using Examples and # {row} ? If not, then perhaps this might be an even more elegant solution: define parameters via that mechanism that are inherited onto "included" stories, and supersede the values used therein. Thus, when an example for GivenStories sets the value for <foo> to X, then the same value of <foo> will be used in the matching story, overriding any "local" definition of <foo>. Make sense?
        Hide
        thomas holm added a comment -

        This feature would solve a lot of problems we are having.
        For example we need to run a scenario with examples for each language locale and for each app version so this would be really helpful.

        Show
        thomas holm added a comment - This feature would solve a lot of problems we are having. For example we need to run a scenario with examples for each language locale and for each app version so this would be really helpful.

          People

          • Assignee:
            Unassigned
            Reporter:
            kk sure
          • Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: