1. Behaviour Driven Development using Cucumber and Java
Srinivas Katakam
Presented to JUG Hyderabad
11-February-2017
2. About the talk
• BDD in a Nutshell
• BDD format
• BDD with Cucumber
• Cucumber Stack and advantages
• Cucumber-JVM
• Using Cucumber and Java with IntelliJ
• Geb
• Demo
• Questions
3. BDD in a Nutshell
BDD is a process designed to
aid the management and the
delivery of software
development projects by
improving communication
between engineers and
business professionals.
In so doing, BDD ensures all
development projects remain
focused on delivering what the
business actually needs while
meeting all requirements of
the user.
4. BDD Format
User Story
As a [X]
I want [Y]
so that [Z]
Scenario
Given some initial
context (the givens),
When an event
occurs,
then ensure some
outcomes.
5. BDD with Cucumber
• Cucumber is an open source
tool that is used to support
Behaviour Driven Development
with plain text specifications
• Implementations of
Cucumber exist for number
of platforms, including Java
6. Cucumber Stack and advantages
A single source of truth
• Cucumber merges specification and
test documentation into one cohesive
whole
Focus on the customer
• Cucumber's executable specifications
encourage closer collaboration,
helping teams keep the business goal
in mind at all times
Less rework
• Protect teams from costly regressions
Cucumber Stack
8. Using Cucumber and Java with IntelliJ
New Maven Project
Add the pom.xml repository and dependencies
Add source folder, “src/test/resources”
Delete the App.java and AppTests.java files
Add the CukesRunner class
Settings -> Plugins -> Search for “Cucumber for Java” and install
Add the feature file and step class
9. Geb
GEB is a Web automation framework using groovy
It is a wrapper over selenium and provides a lot of inbuilt utilities that
will allow the end user to jump into the job of automating their
testcases and validating their application within a short period
Geb provides a enhanced Page Object modelling to its users with the
advantage of reusability and maintainability of tests and framework