1

I am using cucumber and trying to read row from my csv file based on scenario name.

  Feature file :
    Scenario Outline: Verify content of my probblem1


Scenario,                       Title1, Title2, Title3, Title4, Title5
Verify content of my probblem1, Text1,  Text2,  Text3,  Text4,  Text5,
Verify content of my probblem2, Text1,  Text2,  Text3,  Text4,  Text5,
  • I am not sure I fully understand your problem here. you could easily just add a step that reads a csv, and use a scenario outline to provide the name of that csv. Is there some reason this isn't enough? – Tyler MacMillan Apr 13 '18 at 14:11
  • Considering the feature file is your executable specification, it's really not recommended to read your scenarios from Excel, as that would mean that the information needed to understand the scenarios would not be in the feature file, but in the excel. On top of that, you would have to implement reading from the excel yourself (e.g. using Apache POI) while if you just add the values to your feature file, Cucumber will process them for you. – Marit Apr 14 '18 at 05:00
  • 1
    If you are flexible you might wanna use `Gauge` from Thoughworks. It can do all that you are looking for. Cucumber is stuck with features since ages, time to let it rest for good. – MushyPeas Aug 19 '19 at 18:54

2 Answers2

0

The short answer is that reading CSV files from a Scenario written in Gherkin is not supported.

If you want to read data from an Excel file, you have to implement it yourself and call that functionality from your step. As @marit notices, Apache POI may be one option.

Thomas Sundberg
  • 4,098
  • 3
  • 18
  • 25
0

The feature you are looking for 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
QMetry QAF, QMetry Automation Framework,15,TC-001
Selenium ISFW,Infostretch Test Automation Framework,45,111

You can refer documentation and step-by-step tutorial

user861594
  • 5,733
  • 3
  • 29
  • 45
  • did you run using `GherkinScenarioFactory`? Can you provide error details? If your step has Given/When/Then annotation from cucumber then you need to Place `@QAFTestStepProvider` annotation at class defining cucumber steps – user861594 Apr 18 '18 at 15:40
  • @Rock please provide details what is not working so i can help. There are [unit test](https://github.com/qmetry/qaf/blob/master/test/resources/features/gherkin.feature#L41) of QAF passing without issue. – user861594 Apr 27 '18 at 18:11