Bo Han
Bo Han

Reputation: 71

How to loop a cannon cucumber scenario on the data from an external CSV file?

I have an API called VerifyIdentity which returns true or false for an ID.

I also have a CSV file and all the IDs in the file are valid IDs and should be returned True by VerifyIdentity API.

I want to create a feature file to test all the IDs. Is there a way to loop on that CSV file? I know that the cucumber outline can do very similar thing, but I can't manually type those IDs in my tests since there are too many IDs.

Thank you!

By the way, the IDs in the CSV are all the numbers between 1 and 100000. It should also work if there is a way to create a loop-like scenario

Upvotes: 1

Views: 765

Answers (1)

Hitesh
Hitesh

Reputation: 31

Reading CSV files from a Scenario written in Gherkin is not supported. However this feature is supported in gherkin with qaf. You can have examples in CSV/Excel/XML/json/DB

Scenario Outline: Search Keyword using data from file
  When I search for "<searchKey>"
  Then I get at least "<number>" results
  Then it should have "<searchResult>" in search results
Examples: {'datafile':'resources/testdata.csv'}

where your csv file may look like below: searchKey,searchResult,number,TestCaseId

https://qmetry.github.io/qaf/latest/gherkin_client.html

Upvotes: 1

Related Questions