This document summarizes a talk on using Behavior Driven Development (BDD) with Cucumber and Java. The talk covers:
- An overview of BDD and its format using user stories and scenarios
- How Cucumber supports BDD with plain text specifications that can be implemented in multiple languages like Java
- The advantages of Cucumber like having a single source of truth and focusing development on customer needs
- Using Cucumber-JVM for Java projects, including running tests with JUnit and the command line
- Setting up a sample project in IntelliJ with Cucumber
- An overview of the Geb framework for automating web tests in Groovy
- Time for questions at the end
Behaviour Driven Developmentusing 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 aNutshell
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
Asa [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 andadvantages
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
Using Cucumber andJava 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 aWeb 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