Search code examples
intellij-ideacucumberscenariosfeature-file

Nested examples in cucumber scenario outline - List or Map values


I have recently seen a cucumber scenario outline like this. sorry for my bad example below. But the format is in this way. I really wonder if this type of format is supported by cucumber? The nested Data tables. Has any one used this type of nested Data table? If yes is this the below format?

        Scenario Outline: Hello World
     Given I am logged in as <user>
     When I search for <searchTerm>
     Then I add the following to my basket:
        | <item1> |teapot|
        | <item2> |Yorkshire tea|

Examples:
| user | searchTerm |
| Adam | Tea        |

Can i make a data table like above


Solution

  • That's not quite how they work.

    The nested data tables are used by the step that the table is joined to. It's usually used to do multiple of the same thing, using the data table on the inside as an array. This can include headers, or no headers - depending on how you have written your step. Remember - it's all about communication.

    As an example:

    Scenario Outline: Hello World
     Given I am logged in as <user>
     When I search for <searchTerm>
     Then I add the following to my basket:
        | <item1> |
        | <item2> |
    
    Examples:
    | user | searchTerm | item1  | item2         |
    | Adam | Tea        | teapot | Yorkshire tea |