0

I have a seemly simple Cucumber question that I think most of us have encountered. But I do not how to resolve it.

Let's say I have the below scenario outline example. The way it execute is:

1) it retrieve the 1st row of data, use it to execute step 1, 2, 3 in that order

2) then it use 2nd row of data, do the same thing...

3) then the 3rd row...

  Scenario Outline: Test state
    Given <state> <other_state> is used in step 1
    And <state> <other_state> is used in step 2 
    And <state> <other_state> is used in step 3
  Examples: Rainbow colours
    | state    | other_state |
    | missing  | passing     |
    | passing  | passing     |
    | failing  | passing     |

In my case, my data "state" "other_state" is read from a file so I can not put data explicitly in feature file. And I have already created step definition for 'Given' and 'And' steps.

How can I still run the scenario in a outline kind of way? I can get all the data in 'Given', but I can not make the following steps run N number of times in a loop.

halfer
  • 19,824
  • 17
  • 99
  • 186
user1559625
  • 2,583
  • 5
  • 37
  • 75
  • Write a java program that creates the feature file by accessing the excel file with the data filled in and store it in the appropriate location. Then call the cucumber runner – Grasshopper Oct 17 '17 at 10:32

1 Answers1

1

I would work hard on not polluting the feature files with incidental details. It sounds like the incidental details are hidden in files and your problem is how to read them from Gherkin. The short answer on how to read files from Gherkin is not. You don't read files from Gherkin, you read files from the support code that your steps are using.

Thomas Sundberg
  • 4,098
  • 3
  • 18
  • 25
  • The problem is not reading data from the file, but how to RUN THE STEPS MULTIPLE TIMES with the data. I can get alI the data i need, but i can not execute step 1,2,3 in that order over and over with my data. I think you misread my question. – user1559625 Oct 18 '17 at 07:30
  • The execution order is not guaranteed in Cucumber. You are not supposed to run steps in a specific order as this will allow to implement the anti-pattern of steps depending on previous steps. It sounds to me that you are looking for a test tool. There are other tooling that might support you better if you have a system that needs verification in multiple steps as you seem to be looking for. – Thomas Sundberg Oct 20 '17 at 07:35