What are Gherkin feature files?

Photo by Mockup Graphics on Unsplash

Background

What are Gherkin feature files? They’re human-readable documentation that can map to automated tests.

Gherkin is a DSL (domain-specific language) for BDD (behavior-driven development).

Example

Here’s an example of using Gherkin to describe how to search for remarkablemark on Google:

Given I am on "https://www.google.com/"
When I click on the search bar
And I type "remarkablemark"
And I press "Enter"
Then I see in the search results "remarkablemark.org"

Each line is a step:

  • Given sets up the scenario.
  • When describes the action.
  • Then states the expected outcome.
  • And chains successive Given’s, When’s, and Then’s.

Steps can be organized under Scenario’s, and they’re all under a single Feature.

Here’s the Google search with Feature and Scenario:

Feature: Google search
Scenario: Search for remarkablemark
Given I am on "https://www.google.com/"
When I click on the search bar
And I type "remarkablemark"
And I press "Enter"
Then I see in the search results "remarkablemark.org"

Resources

To learn more about the syntax, go to Gherkin Reference.

To see a feature file used as an automated test, check out the cucumber example in webdriverjs-recipes.

--

--

--

remarkablemark.org

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Implementing a Singly Linked List in JavaScript: pt. 3

Elixir — A Tincture for Functional Programming Part 1.3

a magical elixir from a well know game series

Page Speed Optimization for Conversions and SEO

Javascript Coding: Array Quiz

//platform.twitter.com/widgets.js from Twitter https://twitter.com/MacGregorHair

Steps to implement internationalization in React with react-i18next

Add Custom Code Snippets in VS Code

Wordpress to Contentful migration

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
remarkablemark

remarkablemark

remarkablemark.org

More from Medium

Functional Testing Types-1

Continuous Confidence: Dealing With Sunk Cost

How to avoid lack of tests maintenance?

Artificial Intelligence and Software Testing