What is Cucumber?

Cucumber is a framework for writing and executing high level descriptions of your software's functionality. Specifications are written in a concise human readable form. You can read more about Cucumber here

Where do I put the tests?

Cucumber has the following concepts:

What is a Feature?

A feature file is supposed to describe a single feature of the system, or a particular aspect of a feature. Contains an overall description of a feature as well as a number of scenarios.

What is a Scenario?

A scenario is a concrete example that illustrates a business rule. Scenarios are stored in Feature Files. Every scenario consists of a list of steps, which must start with one of the keywords Given, When, Then or And. A feature may contain a background, scenario outline and examples.

The pattern to write a scenario is:

Feature: Search results in Google

  Scenario: Search something in google
    Given I'm at
    When I search for minium github
    Then a link for is displayed

What is a Step?

A step is analogous to a method or function invocation. A step starts with the keywords Given, When or Then.




The purpose of When steps is to describe the key action the user performs.



Then steps are used to describe an expected outcome, or result.


What is a Step definition?

Every step need a step definition to translate plain text Gherkin steps into actions that will interact with the system. A step definition consists of a keyword, a string or regular expression, and a block

When Cucumber executes a Step in a Scenario it will look for a matching Step Definition to execute.

  Scenario: Search something in google
    When I search for minium github

For the step When I search for minium github the step definition is:

When(/^I search for (.*)$/, function (query) {
  var searchbox = $(":input").withName("q");
  var button    = $("button").withAttr("aria-label", "Google Search");


Step definitions are defined in javascript files under steps/*_steps.js.

Which results can a Scenario have?

A scenario has 2 possible result:

Which results can a steps have?

It can have 4 possible result: