# Gherkin + Cucumber
Most product teams write acceptance criteria without realizing they're one step away from automated testing.
If you're already writing "Given/When/Then" scenarios, you're using Gherkin—a language designed specifically for automated testing with Cucumber. Understanding this connection will help you write better acceptance criteria and pave the way for automated tests.
## What is Gherkin?
Gherkin is a language for writing acceptance criteria with five main statements:
- →Scenario — Label for the behavior you're describing
- →Given — Starting state of the scenario
- →When — Specific action the user takes
- →Then — Testable outcome from that action
- →And — Continues any of the other statements
Example:
1Scenario: User logs in successfully
2Given I am on the login page
3When I enter valid credentials
4Then I should see the dashboard
## Why Gherkin + Cucumber?
Written well, Gherkin scenarios serve double duty:
- →Human communication - Product and engineering align on requirements
- →Test automation - Each scenario can become an automated test
## The Cucumber Connection
Cucumber reads Gherkin scenarios and runs them as automated tests. Each line maps to code that performs the actual actions:
- →
Given I am on the login page
→ Code that navigates to the login page - →
When I enter valid credentials
→ Code that fills forms and clicks login - →
Then I should see the dashboard
→ Code that verifies the dashboard appears
## Writing Better Gherkin
Focus on user behavior, not implementation:
- →Good:
When I click the login button
- →Bad:
When I POST to /api/auth/login
Keep scenarios simple:
- →One clear path through the feature
- →Avoid complex branching in single scenarios
Make outcomes testable:
- →Good:
Then I should see "Welcome back!"
- →Bad:
Then the user experience improves
Use consistent language:
- →Reuse steps across scenarios
- →Build a shared vocabulary
## Getting Started
Start by writing better acceptance criteria in Gherkin format. Focus on clarity and consistency. This alone will improve team communication.
Later, when you're ready for automated testing, your well-written scenarios become the foundation for your test suite. No rework required—just connect your existing Gherkin to Cucumber.