Cucumber-js: Scenario Outline with multiple Examples

Created on 6 Jun 2018  ·  16Comments  ·  Source: cucumber/cucumber-js

Hi,
first of all, big thanks to have this JS Gherkin implementation.

My issue:
I have Scenario Outline with some Examples. This scenario contains step with getting endpoint with some url and I would like to have another Examples in this Scenario Outline with parameters of url.
Then I want to run scenario according to first Examples multiplied with another Examples. So if first Examples have e.g 4 rows and second 4 rows = 4 x 4 = 16 runs.

Basically the same as
https://github.com/Behat/Behat/issues/1082

Most helpful comment

https://github.com/Behat/Behat/issues/1082 is that only the last examples table gets executed. I consider that separate from multiplying example tables.

Filling out an example. Are you asking for the following:

Scenario Outline:
  Given <a> and <b>

  Examples:
    | a  |
    | a1 |
    | a2 |
    | a3 |
    | a4 |

  Examples:
    | b  |
    | b1 |
    | b2 |
    | b3 |
    | b4 |

Where it runs 16 scenarios with the combinations a1/b1, a1/b2, a1/b3, a1/b4, a2/b1, etc. It we were to support such a thing I think we need a different keyword instead of overloading Examples as this setup currently becomes 8 scenarios where in the first 4 b is undefined and in the second 4 a is undefined.

All 16 comments

I’m surprised this doesn’t work already. It definitely does on Java and Ruby....

I agree it should be implemented.

https://github.com/Behat/Behat/issues/1082 is that only the last examples table gets executed. I consider that separate from multiplying example tables.

Filling out an example. Are you asking for the following:

Scenario Outline:
  Given <a> and <b>

  Examples:
    | a  |
    | a1 |
    | a2 |
    | a3 |
    | a4 |

  Examples:
    | b  |
    | b1 |
    | b2 |
    | b3 |
    | b4 |

Where it runs 16 scenarios with the combinations a1/b1, a1/b2, a1/b3, a1/b4, a2/b1, etc. It we were to support such a thing I think we need a different keyword instead of overloading Examples as this setup currently becomes 8 scenarios where in the first 4 b is undefined and in the second 4 a is undefined.

@aslakhellesoy is multiplying example tables working in java / ruby? Cucucmber-js correctly deals with multiple examples tables for a single scenario outline.

From what I take from the Behat ticket, what they want to achieve there is not multiplying out the table, but rather grouping examples based on what they express:

    Examples: of ordinary Latin character inputs
      | input |
      | a     |
      | z     |
      | 0     |

    Examples: of Unicode inputs
      | input  |
      | U+0046 |
      | U+0058 |

    Examples: of invalid inputs
      | input  |
      | <      |
      | </     |

Rather than compounding:

    Examples: Usernames
         | username   |
         | admin      |
         | user       |
         | maintainer |
         | moderator  |

    Examples: Passwords
         | password |
         | valid    |
         | invalid  |

I might be wrong though

I misread "multiple" Example tables, which works. Multiplying example tables (matrix multiplication?) does not work. I think that would be a bit hard for people to understand.

Have you considered pairwise to generate a smaller table?

Sorry to mislead you by posting Behat ticket. I need exactly what charlierudolph write, even with different keyword.

Thx.

@znevrly I agree multiplying everything would be confusing when laid against the current examples. I think pairwise is the ideal solution as you can narrow down to a representative set of test cases. @aslakhellesoy do you think we want to build something like pairwise into gherkin? (if we can determine a nice interface)

I don't think we should build pairwise into Gherkin - that would be feature creep. I think it's better to use a standalone tool to generate a table, then paste it into a feature file.

That doesn't not sound very comfortable. Any ideas? :)

Any ideas about what?

To have some keyword to achieve described behavior (multiplying example tables or matrix multiplication) without need to generate tables manually.

Did you realise you only need to run the pairwise tool once to generate a table to paste into a scenario outline? I'm not sure what makes you uncomfortable about that.

But I have dozens feature files with many scenarios. In case of "second" Examples table would be just many copy pasting and it's very clear when is done or not. And in case there will be extra row in "second" Example table I don't need to regenerate all merged tables.

More over with generated tables is not very clear if there are all possible combinations or not. :(

We may add a Gherkin pre-processor API at some point. When we do, I think the functionality you’re asking for should be implemented using that API. It’s not a priority at the moment, so if this is urgent to you I suggest you generate Gherkin files yourself.

how will i use this in examples - Email should be in the format of "first_name.[email protected]"

Is it possible to Pick only one scenario from the Example table? lets say i have

A| B | C|
| Bundle | 'HD' | 'SHP' |
| PZ | 'HD' | 'SHP' |

If from one feature file(lets say helloWorld.feature) i am calling another feature(Print.feature) file which has scenario outline with above table, then is it possible to pick a scenario to run from the first feature file?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  ·  7Comments

zanona picture zanona  ·  4Comments

kozhevnikov picture kozhevnikov  ·  6Comments

hdorgeval picture hdorgeval  ·  3Comments

dblooman picture dblooman  ·  7Comments