0% found this document useful (0 votes)
7 views4 pages

CUCUMBER (1) (1)

The document provides an overview of Cucumber, a testing framework that supports Behavior Driven Development (BDD) using plain English syntax through Gherkin language. It explains the structure of feature files, scenarios, and the use of keywords such as Given, When, Then, and And to define test conditions and actions. The document emphasizes the user-focused nature of BDD and the collaboration between technical and non-technical teams in the testing process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

CUCUMBER (1) (1)

The document provides an overview of Cucumber, a testing framework that supports Behavior Driven Development (BDD) using plain English syntax through Gherkin language. It explains the structure of feature files, scenarios, and the use of keywords such as Given, When, Then, and And to define test conditions and actions. The document emphasizes the user-focused nature of BDD and the collaboration between technical and non-technical teams in the testing process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Yes-M Systems LLC - Cucumber Autmation Testing

CUCUMBER
Behavior Driven Development

In BDD , we write tests first and the add application code.

Tests are written in plain descriptive English type grammar

Tests are explained as behavior of application and are more user-focused

Using examples to clarify requirements

Cucumber:
Cucumber is a testing framework which supports Behavior Driven Development (BDD). It
lets us define application behavior in plain meaningful English text using a simple grammar
defined by a language called Gherkin

Selenium is a web browser automation tool. Cucumber is a behavior-driven development


tool that can be used with Selenium (or Appium). Selenium is preferred by technical teams
(SDETs/programmers). Cucumber is typically preferred by non-technical teams (business
stakeholders and testers)

Gherkin keywords:
Feature: Keyword

Each Gherkin file begins with a Feature keyword. Feature defines the logical test
functionality you will test in this feature file. For e.g, if you are testing a payment
gateway your Feature will become Payment Gateway or if you are testing the LogIn
functionality then the Feature will become Login. The idea of having a feature file is
to put down a summary of what you will be testing. This will serve as the
documentation for your tests as well as a good point to start for a new team member.
Note that a feature keyword is present at the starting of the feature file.

Feature: LogIn Action Test

Or

Feature: LogIn Action Test

Scenario: Keyword

Yes-M Systems LLC, http://myyesm.com Cucumber Automation Testing


Yes-M Systems LLC - Cucumber Autmation Testing

Each Feature will contain a number of tests to test the feature. Each test is called
a Scenario and is described using the Scenario: keyword.

Scenario: Search a product and add the first result/product to the User basket

Or

Scenario: Successful LogIn with Valid Credentials

A scenario is equivalent to a test in our regular development process. Each


scenario/test can be basically broken down into three parts:

• Precondition to the test, which represent with (Given) keyword


• Test step execution, which represent with (When) keyword
• Verification of the output with expected result, which represent with (Then)

Scenario Outline: Keyword


In situations where one wants to execute the same Scenario with various
combinations of values or arguments, one could use the Scenario Outline. It
facilitates the testing of the same scenario with multiple arguments. The multiple
arguments passed against the same scenario outline are called Examples which is
another keyword in Cucumber

Given: Keyword
Given defines a precondition to the test. For e.g. In the shopping website, assume
that the LogIn page link is only present on the Home Page, so the precondition for
clicking the LogIn link is that the user is at the Home Page. If user is not at the Home
Page, user would not be able to enter Username & Password. This precondition can
be expressed in Gherkin like this:

Scenario: Successful LogIn with Valid Credentials

Given User is on Home Page

When User Navigate to LogIn Page

When: Keyword
When keyword defines the test action that will be executed. By test action we mean
the user input action.

Scenario: Successful LogIn with Valid Credentials

Yes-M Systems LLC, http://myyesm.com Cucumber Automation Testing


Yes-M Systems LLC - Cucumber Autmation Testing

Given User is on Home Page

When User Navigate to LogIn Page

Here user is performing some action using When keyword, clicking on the LogIn link.
We can see that when defines the action taken by the user. It's the event that will
cause the actual change in state of the application.

Then: Keyword
Then keyword defines the Outcome of previous steps. We can understand it best by
looking at the test above and adding a Then step there.

Feature: LogIn Action Test

Description: This feature will test a LogIn and LogOut functionality

Scenario: Successful Login with Valid Credentials Given User is on Home Page

When User Navigate to LogIn Page

And User enters UserName and Password

Then Message displayed LogIn Successfully

Here we can see that Then is the outcome of the steps above. The reader of this
test would easily be able to relate to Then step and would understand that when the
above conditions are fulfilled then the Then step will be executed.

And: Keyword
And keyword is used to add conditions to your steps. Let's look at it by modifying our
example a little

Feature: LogIn Action Test

Description: This feature will test a LogIn and LogOut functionality

Scenario: Successful Login with Valid Credentials

Given User is on Home Page

When User Navigate to LogIn Page

Yes-M Systems LLC, http://myyesm.com Cucumber Automation Testing


Yes-M Systems LLC - Cucumber Autmation Testing

And User enters UserName and Password

Then Message displayed Login Successfully

Or

Feature: LogIn Action Test

Description: This feature will test a LogIn and LogOut functionality

Scenario: Successful Login with Valid Credentials

Given User is on Home Page

And LogIn Link displayed

When User Navigate to LogIn Page

And User enters UserName and Password

Then Message displayed Login Successfully And LogOut Link displayed

Yes-M Systems LLC, http://myyesm.com Cucumber Automation Testing

You might also like