Cucumber BDD Tutorial: From Gherkin to CI
A free Cucumber BDD course: three amigos and example mapping, declarative Gherkin, Cucumber-JVM with Selenium, expressions, hooks and DI, outlines and tags, Cucumber-JS with Playwright, Behave, Reqnroll and CI on TestingBot.
What you will learn
- Cucumber BDD Tutorial: From Gherkin to CI
- BDD Testing Starts Before the Code: Three Amigos
- Writing Good Gherkin: Declarative Scenarios
- Cucumber with Java and Selenium: First Scenario
- Step Definitions, Cucumber Expressions, Parameter Types
- Hooks and Sharing State with PicoContainer
- Scenario Outlines, Tags and Background
- Cucumber-JS with Playwright
- Parallel Runs, Reports and CI on TestingBot
- Other BDD Frameworks: Behave and Reqnroll
- BDD Anti-Patterns and How to Fix Them
- Knowledge check
On this page
Last reviewed November 2026 against Cucumber-JVM 8.0.4, Selenium Java 4.52.0, JUnit Platform 6.1.3, Cucumber-JS 13.3.0, Playwright 1.65.0, Behave 1.3.3 and Reqnroll 3.3.4.
Behaviour-Driven Development (BDD) is a way for a team to agree on what a feature should do, using concrete examples, before anyone writes the code. Cucumber is a tool that turns those examples into automated tests. The two are often treated as one thing, and that confusion is behind most BDD suites that end up slow, brittle and ignored. This course teaches both, in that order: the practice first, then the tool.
BDD in one example#
A product owner, a developer and a tester talk about signing in. Instead of writing "users must be able to sign in", they agree on examples:
Feature: Signing in to the secure area
Members sign in with a username and password to reach the secure area.
Wrong credentials are rejected with a message that says which part was wrong.
Scenario: Tom signs in with his own password
Given Tom has an account
When Tom signs in with his password
Then he is in the secure area
That text is Gherkin: a small, structured language with keywords such as Feature, Scenario, Given, When and Then. Everyone in the conversation can read it and say "yes, that is what we mean" or "no, what happens if...". The same file is then executed by Cucumber, which matches each step to a piece of code (a step definition) that drives the application, here through Selenium.
So a BDD suite has three layers:
| Layer | Written by | Answers |
|---|---|---|
| Feature files (Gherkin) | The whole team, in business language | What should the system do? |
| Step definitions (Java, JavaScript, Python, C#...) | Developers and testers | How do we check it? |
| Automation library (Selenium, Playwright, an HTTP client...) | Developers and testers | How do we talk to the system? |
What Cucumber is not#
- Not a test framework you add to get "BDD". Cucumber executes examples. If nobody outside the test team reads or writes the feature files, you have an extra layer of indirection on top of ordinary UI tests, and the cost without the benefit. Chapter 1 is about the conversations that make the feature files worth having.
- Not a UI testing tool. Cucumber does not know about browsers. Many of the best scenarios are checked through an API or directly against domain code, which is faster and less fragile. This course uses Selenium and Playwright because a browser is the most common target and the hardest one to get right.
- Not a scripting language for testers. Scenarios full of "click", "type" and CSS selectors are the most common BDD anti-pattern (chapter 10). Gherkin describes behaviour; the step definitions hide the mechanics.
Is BDD worth it?#
BDD pays off when the hard part of a feature is understanding the rules: pricing, permissions, eligibility, workflows with many states. The examples flush out misunderstandings before they become bugs. It pays off less for purely technical work, or when the same person writes the requirement, the code and the test. Use it where the conversation is valuable, and plain unit or end-to-end tests elsewhere. Nothing stops one repository from having both.
Which language?#
Cucumber has official implementations for many languages. This course uses Cucumber-JVM with Java for the main project, because it is the most widely used combination, and repeats the essentials with Cucumber-JS and Playwright in chapter 7. Chapter 9 shows the same feature with Behave (Python) and Reqnroll (.NET, the successor to SpecFlow). The Gherkin is identical in all of them; only the step definitions change.
How the course is organised#
- BDD as a collaboration practice: three amigos and example mapping
- Writing good Gherkin
- Cucumber-JVM with Java and Selenium: your first scenario, locally and on TestingBot
- Step definitions, Cucumber expressions and parameter types
- Hooks and sharing state between steps with dependency injection
- Scenario Outlines, tags and Background
- Cucumber-JS with Playwright
- Parallel runs, reports, CI and pass/fail status on TestingBot
- Other flavours: Behave for Python and Reqnroll for .NET
- BDD anti-patterns
- A knowledge check
All examples run against public demo pages, so you can copy them and see them pass: the login form at the-internet.herokuapp.com and the Playwright team's TodoMVC demo. Every cloud example in the course was run on the TestingBot grid.
Prerequisites#
- Basic Java (classes, constructors, annotations). Chapter 7 needs basic JavaScript, chapter 9 reads Python and C#.
- JDK 17 or newer (Cucumber-JVM 8 requires 17; the project compiles with
release17 and was run on Java 23), Maven 3.9, and Chrome installed locally. - Node.js 22 or newer for chapter 7.
- A TestingBot account for the cloud runs (the free trial is enough).
If you want to go deeper on the Selenium side, the Selenium Java tutorial with TestNG covers waits, parallel drivers and grids in detail, and the Page Object Model course explains the page classes that step definitions should call.
A note on certification: the course and its knowledge check are free and need no account. If you want something to show an employer, the optional TestingBot certification asks for a passed exam and your Cucumber suite running on TestingBot. It is issued by TestingBot, not by the Cucumber project.