×
☰ See All Chapters

How Cucumber Framework Works

When you run cucumber framework, it reads the test steps from a file called as feature file. These feature files have the file extension as feature. For example login.feature. Cucumber examines feature files for scenarios to test, and runs the scenarios against application under test. Feature file has list of steps written in Gherkin language. Gherkin language is a set of rules and syntax. Cucumber can understand only these feature files with gherkin language.

After cucumber read test steps from feature files, it needs the step definition to run the steps. Those step definitions can be made available by using any of the automation frameworks like selenium, puppeteer etc… In our tutorial we are using selenium to write the step definitions.

Cucumber maps the business-readable gherkin language of each step into selenium code to carry out whatever action is being described by the step.  If the selenium code in the step definition executes without error, Cucumber proceeds to the next step in the scenario. If all steps are executed without any error from selenium definition, it marks the scenario as having passed. A feature file can have any number of scenarios, if any of the steps in the scenario fail; Cucumber marks the scenario as failed and moves on to the next scenario to test. Cucumber prints the result of each step and each scenario showing you exactly what is working and what isn’t.how-cucumber-framework-works-0
 

All Chapters
Author