0

I am planning to work on the Cucumber feature file with Groovy code (Katalon Studio) for step definitions. I wanted to use the excel file in Cucumber file or to see is there any other option to use it.

I have not yet tried as of now any other option. I am thinking just passing the cucumber step file without any parameter and then using the excel file with in the step definition and access excel file and get the corresponding value.

I see there is a post in this forum suggesting to use QMetry Automation Framework for this type of question. But it does not look like this will help on this or should I use the passing the row index from cucumber file and based on that retrieve the value. Please guide on this.

Handling excel spreadsheets with Cucumber Scenario Outline

1

2 Answers 2

3

You should know that this is not supported by Cucumber.

As specified in the FAQ:

"We advise you not to use Excel or csv files to define your test cases; using Excel or csv files is considered an anti-pattern.

One of the goals of Cucumber is to have executable specifications. This means your feature files should contain just the right level of information to document the expected behaviour of the system. If your test cases are kept in separate files, how would you be able to read the documentation?

This also means you shouldn’t have too many details in your feature file. If you do, you might consider moving them to your step definitions or helper methods. For instance, if you have a form where you need to populate lots of different fields, you might use the Builder pattern to do so."

Sign up to request clarification or add additional context in comments.

8 Comments

Thank You so much, Marit for your clarification. As mentioned in my question, I am using the Cucumber & Groovy, I am planning to keep the test data in the excel file and read/pass the test data to my test cases during the execution. OR instead of passing the data in cucumber file, shall I pass the reference row number through cucumber feature file and read the excel sheet in the Groovy Script (step definition) alone ? I can pass the parameters in cucumber with scenario outline, but I wanted to use the excel file as I will have many columns in few of the test cases ! Can you please advise?
The idea of using Gherkin is that the scenarios are human readable. That will not work if you store the test data in Excel. Cucumber's opinion is: don't store test data in Excel. (Which is why it is not supported!). Use the test data that is needed to understand a specific Scenario / Example in the Gherkin (feature file), and put the rest of the data you need in a helper method. You can use the builder pattern to build your objects.
Really appreciate your help, Marit I can pass the data through Scenario outline as parameters. But using the excel it would be more clear and can control the execution also. what do you suggest on when I just use cucumber steps without parameter and import the excel sheet in the groovy script and pass the values ? OR passing reference no through scenario outline from cucumber and get the particular row in excel sheet at groovy script. how does it work ? You mentioned about builder pattern, can you please suggest with example how I can use in my test ?
I'd suggest either using Cucumber, OR using Excel. I cannot help you with how to read your data from Excel in Groovy. Have a look at Apache POI.
Thank you so much, Marit. Yeah.. I looked at the Apache POI and I see these constructors are being used in Groovy for excel retrieval. In this case, I will not be using the cucumber feature file. Now, it is clear that I can use either Cucumber or Excel File. What do you suggest for the best option using parameters through cucumber feature file OR excel file reading in Groovy ?
|
0

If you are using cucumber java 5+ you can add qaf-cucumber dependency. It should work with groovy as well. It will enable to have examples from external source like CSV, XML, JSON, EXCEL, DB.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.