Search code examples
cucumberautomated-testscalabashgherkin

How to use more than one parameter set in Cucumber for test automation?


Is there any possibility to declare more than one parameter set for a test in Cucumber? To make clear what I would like to achieve I will give a short example:

And I do enter something "Example"
 And I have a table with variable:
 |parameter1|value|
 |parameter2|value|
 |parameter3|value|

This is how a feature file looks like, and now my question is how to use different sets of parameters and values, so that I can run the testcase more than once for different values that are selected. I know that this is possible with testng and junit, but I don't know if there is an option for calabash tests.

The only solution I found was that I just copy the testcase and change the values by hand, but this is not what I'm looking for.

Thanks for any help.


Solution

  • You can do almost exactly like you have highlighted there. This is taken from http://behat.readthedocs.org/en/v2.5/guides/1.gherkin.html

    Scenario Outline: Eating
      Given there are <start> cucumbers
      When I eat <eat> cucumbers
      Then I should have <left> cucumbers
    
      Examples:
        | start | eat | left |
        |  12   |  5  |  7   |
        |  20   |  5  |  15  |
    

    Also you probably know this, but the features are written in Gherkin so any tips on how to do them smarter you could read more about Gherkin.