← Back to libraryQuestion 248 of 468
🥒Cucumber / BDDBeginner

What is Cucumber

📌 Definition:

Cucumber is a popular BDD tool that runs executable specifications written in Gherkin. It maps plain-language steps in feature files to automation code (step definitions), producing tests that read like documentation.

📖 Detailed Explanation:

Cucumber parses .feature files written in Gherkin, matches each step to a step-definition method (the 'glue' code) via annotations, and executes them, producing readable reports. It supports many languages (Java, JavaScript via CucumberJS, Ruby, etc.) and integrates with JUnit/TestNG and Selenium/Playwright for the actual automation. Cucumber itself does NOT automate the browser — it orchestrates plain-language scenarios and delegates the doing to your automation library in the step definitions. Its strengths are living documentation and business readability; its cost is the extra glue layer, which is only worth it when non-technical stakeholders actually read the scenarios.

🔑 Key Points:
  • Runs Gherkin feature files by mapping steps → step definitions
  • Cucumber orchestrates; your library (Selenium/Playwright) does the automation
  • Multi-language (Java, CucumberJS, etc.); integrates with JUnit/TestNG
  • Value = living docs + readability; cost = the glue layer
🌍 Real-World Example:

A .feature file's step 'When the user logs in with valid credentials' is matched to a Java method annotated @When that calls the LoginPage Selenium code — Cucumber ties the sentence to the action.

🎯 Scenario-Based Interview Question:

Does Cucumber automate the browser by itself? Explain what it actually does.