jeudi 27 juin 2019

How to pass a data from some json file to Gherkin feature file

I want to parameterize my gherkin feature file steps by taking data from some other JSON file. Any suggestions for this. I searched almost everywhere but couldn't find answers.

I am aware of scenario where examples being used with multiple values for a variable using scenario outline in gherkin feature file but not looking for that.

Currrently I am using like this and below values in quotes are being passed to step definitions

    Scenario: Buy last coffee
        Given There is "Starbucks" coffee
        And I added "Sugarless" syrup

Expected: I want to get data of variables from JSON file or any other file also and pass these data values to step definition functions. is it possible?

gherkin feature file:

    Scenario: Buy last coffee
        Given There is "${data.coffeeshop}" coffee
        And I added "${data.sugarType}" syrup

data.json:

    {
        "coffeeshop": "starbucks",
        "sugarType": "Sugarless",

    }

Aucun commentaire:

Enregistrer un commentaire