Cucumber Interview Questions
1. Cucumber execution starts from where ?
Ans: Cucumber execution will start with support. In support first it will load the env.rb file then it will load hooks.rb and then it will start to execute feature file scenario steps.
2. what is support, env.rb and hooks.rb ?
Ans: Support is a folder where we can setup cucumber related support.
Env.rb file will be used to load the required libraries for cucumber scenario execution
hooks.rb we will add hooks like before, after, beforeStep and afterStep hooks
3. What is profile in cucumber ?
Ans: We can create Cucumber profiles to run specific features and step definitions
We can use the following command to execute a cucumber profile
cucumber features -p <profile_name>
Ex: cucumber features -p regression
4. What is cucumber.yml file in cucumber ?
Ans: in cucumber.yml file we will create profiles
5. What are before, after, beforeStep and afterStep hooks?
Ans: Before: execute the feature file execution
After: executes after the feature file execution
BeforeStep: executes before each step execution
AfterStep: executes after each step execution
6. What are cucumber tags? why we use the tags ?
Ans: cucumber tags used to filter the scenarios. We can tag the scenarios and we can execute the scenarios based on tags,
We can add tags to scenarios with @
We can use the following command to execute a cucumber tagged scenarios
cucumber features -t @<tag_name>
Ex: cucumber features -t @test
7. what is cucumber dry run ?
Ans: Cucumber dry run is used to compile cucumber feature files and stepDefinitions. If there are any compilations errors it will show when we use dry run
Ex: Cucumber features –dry-run
8. What are the maximum number of scenarios and scenario steps that we can use in a single feature file ?
9. What is scenario outline ?
Ans: Scenario outline is used to execute the same scenario with different test data.
we will add test data to the examples section
10. What are the keywords that we use in cucumber scenario steps ?
Ans: We use Given, when, Then, And and But keywords in cucumber scenario steps
11. Is it mandatory to use the keywords while writing scenario steps ?
Ans: No it is not mandatory to used keywords while writing scenario steps.
We can write the scenario steps like the following without using keywords
* I am on the landed page
12. How to generate cucumber execution reports ?
We can use the following command to generate HTML reports.
–format html –out report.html –format pretty
13. How to run a particular scenario from a feature file ?
We can run particular scenario from a feature file by giving the scenario line number
Ex: cucumber features/test.feature:21