BDD Cucumber Cheat Sheet
BDD Cucumber Cheat Sheet
designed by describing how it behaves. BDD offers the ability to enlarge the pool
of input and feedback to include business stakeholders and end users like Scrum
Master, Product Owner, Business Analyst etc., who may not even have software
BDD development knowledge.
Software tool based on Behavior Driven Development (BDD) framework which is
used to write acceptance tests for the web application. The tests are written in
easily readable and understandable format for Business Analysts, Developers and
Cucumber Testers.
Shifting from thinking in "tests" to thinking in "behavior"
Collaboration between Business stakeholders, Business Analysts, QA Team and
developers
Driven by Business Value
Extends Test-Driven Development (TDD) by utilizing natural language that non-
technical stakeholders can understand
BDD frameworks such as Cucumber or JBehave are an enabler, acting a "bridge"
between Business & Technical Language
BDD is popular and can be utilized for Unit level test cases and for UI level test
Features of BDD cases.
The Feature keyword's aim is to collect relevant scenarios and provide a high-
Feature level description of a software feature.
The scenarios are written based on the expected behavior of the software and it
Scenario is tested to check if it matches said scenarios.
Step Each line in a scenario is called a step
Given Describes the initial steps of pre-condition before the start of a test
When Describes user actions during a test or steps performed
Then Describes test results or outcome from When actions
Between any two statements, it gives the logical AND condition. AND can be
And combined with the GIVEN, WHEN, and THEN statements
It denotes a logical OR relationship between two propositions. OR can be
But combined with the GIVEN, WHEN, and THEN statements
The Background section describes any common context to be established before
Background each scenario.
Cucumber scenarios become automated tests with the addition of what are
called step definitions. A step definition is a block of code associated with one or
Step Definitions more steps by a regular expression
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.0.0</version>
Cucumber Maven <scope>test</scope>
Dependency </dependency>
Feature: Search in Google Home Page
Examples:
| username | password | status |
| username1 | password1 | Successful |
Sample Scenario | username1 | password2 | Unsuccessful |
Outline Example | username2 | password3 | Unsuccessful |
Feature: Search in Google Home Page
Background:
Given Google Home Page Open
And Search Text Box is visible and Enabled
@Smoke @Regression
Scenario: Search Cucumber Tutorial in Google Home Page
When User Search a Course with Keyword Cucumber Tutorial
And Hit Enter
Then All Courses related to Cucumber Tutorial should be displayed
@Regression @Integration
Scenario: Search Java Tutorial in Google Home Page
When User Search a Course with Keyword Java Tutorial
Sample Cucumber And Hit Enter
Tags and Background Then All Courses related to Java Tutorial should be displayed
@RunWith(Cucumber.class)
@CucumberOptions(
features = ("src/test/java/Features"),
glue = ("StepDefinitions"),
//tags = ("@Integration"),
//tags = ("not @Integration"),
tags = ("@Integration or @UAT"),
//tags = ("@Integration and @Regression"),
publish = true,
plugin = ("pretty"),
monochrome = true
)