Post on 21-Jan-2017
Let’s cook cucumber!!
vodQA Pune 2016
Pranjali Talekar
Amit Gundiyal
Abhay Dalvi
Pranathi Birudugadda
Agenda
Welcome note, Expectation setting, Group split up
Installations
Discussion about BDD and Cucumber
Setup project framework
Hands-on workshop
Advanced Features Demo
Q&A + Feedback
#vodqa#thoughtworks
INTRODUCTION TO BDD
BDD is...
“Behaviour-driven development is about implementing an application by describing its behaviour from the perspective of its stakeholders”
- Dan North
BDD (Contd…)
It is an agile software development practice that has evolved from TDD (Test Driven Development).
The premise of BDD is to bring technology and business together.
So, As the name suggests, the practice recommends defining the behavior upfront and using the same to drive the product development.
It has evolved from TDD. So there was something amiss in TDD that led to this evolution. Right ?
No clarity of how much to test. i.e. should we test for negative numbers, should we test for decimal etc. There is a clear chance of missing an expected behavior of the method while implementing it.
It is not driven through a specification or the so called desired behavior. And because of this, the boundaries are not clear.
Why BDD ?
MindsetTooling support
BDD expects the desired behavior to be written in a Given, When, Then format...
Given describes the pre-requisites for the expectationWhen describes the actual steps to carry on the effect
of the expectationThen describes the verification that the expectations
were met.
How to adopt BDD ?
Benefits of BDDUsability
System functionality is more deliberateDeveloper is placed into the paradigm of a user of the systemFewer defects
Live documentationLiving specificationTests describe the behaviour of the system
Higher code qualityTestable code tends to follow better design patterns ( more modular code , flexible ,
understandable etc).
Confidence Tests cover smaller, incremental slices of the system.Tests act as safety net covering existing functionality.
Faster Delivery Tests allow new features to be added more easily without breaking existing ones.Misunderstanding of requirements appear earlier in development cycle.
Popular BDD testing Tools
Cucumber (https://cucumber.io)
Jasmine (http://jasmine.github.io)
JBehave (http://jbehave.org)
Concordian (http://concordion.org)
easyb (http://easyb.org)
Introduction To Cucumber
❏ Type : Behavior driven development framework / Collaboration tool / Test tool
❏ Written in : Ruby❏ Operating system : Cross-platform❏ Supports about 60+ languages❏ Automation can be written in own favorite language ( Ruby,
Java, c#.net , JavaScript, Scala, Groovy, Jython, Python, Perl, C++ etc)
❏ Helps to execute plain text functional descriptions as automated tests
❏ Writing scenarios before code enables programmers to be guided by an unambiguous specification
How Cucumber executes a scenario ?
INTRODUCTION TO FRAMEWORK
Framework Ecosystem
In a tool we want...
Simplicitybecause who doesn’t like simple!!
Maintainabilitybecause everyone has been on a long running project and we know it is hell to keep tests working
Customizedbecause we all have our own preferences
Speedbecause we all have that need for speed
Understanding Gherkin Syntax
Feature: Cucumber mandates to write a brief feature description of the scenarios you want to write in a feature file.Provide a high-level description of a software feature, and to group related scenarios.
Scenario: Before writing any scenario it also mandates the user to write a brief scenario description.
Given/When/Then/And - Every step in your scenario would be starting with one of them.
Example - Gherkin Syntax
Given [Pre - condition]
When [Action performed]
Then [Result]
Example:Feature: Refund item
Scenario: John returns a faulty microwave
Given John has bought a microwave for $100 And he has a receipt When he returns the microwave Then John should be refunded $100
HANDS ON
Advanced Features Demo
Data driven Execution
Table driven execution
Background
Hooks
Tags
Running through CLI ( JUnit way ).
Reports
Suggested Reading
http://dannorth.net/introducing-bdd/
http://behaviourdriven.org/
http://guide.agilealliance.org/guide/bdd.html
http://dannorth.net/2012/05/31/bdd-is-like-tdd-if/
http://lizkeogh.com/behaviour-driven-development/
http://lizkeogh.com/2012/05/30/showcasing-the-language-of-bdd/
http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-
user-stories.html
The Cucumber Book
THANK YOUFor questions or suggestions:
vodqa-pune@thoughtworks.compranathi.b@thoughtworks.comabhayda@thoughtworks.com
amit.gundiyal@thoughtworks.compranjalt@thoughtworks.com