Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
BDD using Cucumber 
By Ashish Mishra
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
10 Sec Intro 
Ashish Mishra 
20+ years experience 
Masters in C...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Ashish Mishra 
QAAgility Technologies Pvt. Ltd. – Founder Direc...
Confidential | Copyright © QAAgility Technologies Pvt Ltd
Confidential | Copyright © QAAgility Technologies Pvt Ltd
Confidential | Copyright © QAAgility Technologies Pvt Ltd
Confidential | Copyright © QAAgility Technologies Pvt Ltd
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Tools Never Solve Problems 
•Fool with a tool is still a fool 
...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Goal 
•Introduce Cucumber tool for Behavioral Driven Development
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
What is BDD 
•Hint: It is not about Test Automation
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Software – What can go wrong? 
•Implementation Defects 
•Requir...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Facts 
•50-60% of issues identified by testers can be linked to...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Requirements – often misunderstood
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Scrum 
US 1 and 2 
US 3 
US 1 ,2 ,3
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
BDD 
Business 
•Domain driven design 
Technology 
•Test driven ...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
describe the 
behavior 
of your software 
in a very understanda...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Cucumber is Ruby-based BDD framework
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
What about Java? 
Java: Cucumber-JVM 
•Released in April 2012 
...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
1 Describe Behaviour 
2 Write step definition 
3 Run and fail 
...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Writing Scenario's in Cucumber 
•Scenarios are organized togeth...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Behavior 
Feature: <short description> 
<story> 
<scenario 1> 
...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
BDD Feature 
Feature: Depositing money in to a User account 
Sc...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Gherkin 
Gherkin is the language that Cucumber understands. It ...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
How does BDD help? 
•All stakeholders involve in discussion 
•S...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
User Story and Scenario 
Title (one line describing the story) ...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Scenarios 
Story: Account Holder withdraws cash 
As an Account ...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Group Exercise 
•Read the ATA SSC Vision document and the user ...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Attributes of Good Feature document 
•Complete 
•Testable 
•Spe...
Confidential | Copyright © QAAgility Technologies Pvt Ltd 
Thank You. 
ashish.mishra@qaagility.com 
in.linkedin.com/in/ash...
Upcoming SlideShare
Loading in …5
×

Bdd using Cucumber

975 views

Published on

How to do Behavior Driven Development (BDD) using Cucumber and avoid common pitfalls

Published in: Software
  • Be the first to comment

Bdd using Cucumber

  1. 1. BDD using Cucumber By Ashish Mishra
  2. 2. Confidential | Copyright © QAAgility Technologies Pvt Ltd 10 Sec Intro Ashish Mishra 20+ years experience Masters in Computer Science Author of Selenium Book by McGrawHill I am an Agilist! @ash1shm
  3. 3. Confidential | Copyright © QAAgility Technologies Pvt Ltd Ashish Mishra QAAgility Technologies Pvt. Ltd. – Founder Director M.S. Computer Science, Stevens Institute of Technology, USA; PG Certificate in Business Management from City University of NY (CUNY); B.E. CSE, Marathwada University. Certified Trainer for Agile Testing, Certified Scrum Master, Expertise in Account management, application delivery and business analysis 20+ years of IT Industry experience with: Larsen & Toubro Infotech Ltd, India JPMorgan, India Chase Manhattan Bank, USA IBM, USA Prudential Insurance, USA Seasoned techno-functional entrepreneur with a track record of exhibiting innovative thought leadership, being self-driven, exceeding expectations and applying high standards. He belongs to the group of respectable innovators in the area of processes consulting & automation testing. He is the executive member of the Indian Testing Board (ITB) and founder of the Agile Testing Alliance (ATA). Experience in software testing, development, corporate training and public domain training. Over the period he has worked on number of projects as Account Manager, Test Manager, Programmer and Tester. His core expertise lies in Manual Testing, Test Automation and Test Management. Capital Markets related technology projects in delivering e2e mid to large size projects in the area of application development, re- engineering, process consulting and QA. Worked with clients spread across the globe, USA, UK, Germany, China, Singapore, Australia and Japan. Published author of the book "A Practitioner's Guide To Test Automation Using Selenium" by Tata McGraw-Hill.
  4. 4. Confidential | Copyright © QAAgility Technologies Pvt Ltd
  5. 5. Confidential | Copyright © QAAgility Technologies Pvt Ltd
  6. 6. Confidential | Copyright © QAAgility Technologies Pvt Ltd
  7. 7. Confidential | Copyright © QAAgility Technologies Pvt Ltd
  8. 8. Confidential | Copyright © QAAgility Technologies Pvt Ltd Tools Never Solve Problems •Fool with a tool is still a fool •Use right tool for the right problem
  9. 9. Confidential | Copyright © QAAgility Technologies Pvt Ltd Goal •Introduce Cucumber tool for Behavioral Driven Development
  10. 10. Confidential | Copyright © QAAgility Technologies Pvt Ltd What is BDD •Hint: It is not about Test Automation
  11. 11. Confidential | Copyright © QAAgility Technologies Pvt Ltd Software – What can go wrong? •Implementation Defects •Requirement Defects
  12. 12. Confidential | Copyright © QAAgility Technologies Pvt Ltd Facts •50-60% of issues identified by testers can be linked to Requirement Defects •100-200% expensive to fix than other defects because the code is already written
  13. 13. Confidential | Copyright © QAAgility Technologies Pvt Ltd Requirements – often misunderstood
  14. 14. Confidential | Copyright © QAAgility Technologies Pvt Ltd Scrum US 1 and 2 US 3 US 1 ,2 ,3
  15. 15. Confidential | Copyright © QAAgility Technologies Pvt Ltd BDD Business •Domain driven design Technology •Test driven development
  16. 16. Confidential | Copyright © QAAgility Technologies Pvt Ltd describe the behavior of your software in a very understandable way
  17. 17. Confidential | Copyright © QAAgility Technologies Pvt Ltd Cucumber is Ruby-based BDD framework
  18. 18. Confidential | Copyright © QAAgility Technologies Pvt Ltd What about Java? Java: Cucumber-JVM •Released in April 2012 •Pure Java •Supports: Java, JavaScript, JRuby, Scala, Python, Groovy, Jython and JRuby
  19. 19. Confidential | Copyright © QAAgility Technologies Pvt Ltd 1 Describe Behaviour 2 Write step definition 3 Run and fail 4 Write code to make step pass 5 Run and pass
  20. 20. Confidential | Copyright © QAAgility Technologies Pvt Ltd Writing Scenario's in Cucumber •Scenarios are organized together into features •Each feature is represented as a plain text file. •Feature files must have the “.feature” extension •Each feature can contain many scenarios
  21. 21. Confidential | Copyright © QAAgility Technologies Pvt Ltd Behavior Feature: <short description> <story> <scenario 1> <scenario n> WHO? As a <role> WHAT? I want <feature> WHY? so that <business value> Scenario: <description> Given <preconditions, context> [And] <additional preconditions> When <action, behaviour> Then <postconditions> [And] <additional postconditions>
  22. 22. Confidential | Copyright © QAAgility Technologies Pvt Ltd BDD Feature Feature: Depositing money in to a User account Scenario: Depositing money in to User's account should add money to the User's current balance Given a User has valid bank account And a User has $X money in their account When $Y is deposited in to the account Then the balance should be $(X+Y) This is Gherkin
  23. 23. Confidential | Copyright © QAAgility Technologies Pvt Ltd Gherkin Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software’s behavior without detailing how that behavior is implemented. •Easy to read •Easy to understand •Easy to discuss •Easy to parse
  24. 24. Confidential | Copyright © QAAgility Technologies Pvt Ltd How does BDD help? •All stakeholders involve in discussion •Specifications having acceptance tests built into them •As the software evolve the tests also updated •Specifications are about how the system should behave in various scenarios
  25. 25. Confidential | Copyright © QAAgility Technologies Pvt Ltd User Story and Scenario Title (one line describing the story) Narrative: As a [role] I want [feature] So that [benefit] Acceptance Criteria: (presented as Scenarios) Scenario 1: Title Given [context] And [some more context]... When [event] Then [outcome] And [another outcome]...
  26. 26. Confidential | Copyright © QAAgility Technologies Pvt Ltd Scenarios Story: Account Holder withdraws cash As an Account Holder I want to withdraw cash from an ATM So that I can get money when the bank is closed Scenario 1: Account has sufficient funds Given the account balance is $100 And the card is valid And the machine contains enough money When the Account Holder requests $20 Then the ATM should dispense $20 And the account balance should be $80 And the card should be returned Scenario 2: Account has insufficient funds Given the account balance is $10 And the card is valid And the machine contains enough money When the Account Holder requests $20 Then the ATM should not dispense any money And the ATM should say there are insufficient funds And the account balance should be $20 And the card should be returned Scenario 3: Card has been disabled Given the card is disabled When the Account Holder requests $20 Then the ATM should retain the card And the ATM should say the card has been retained Scenario 4: The ATM has insufficient funds ...
  27. 27. Confidential | Copyright © QAAgility Technologies Pvt Ltd Group Exercise •Read the ATA SSC Vision document and the user stories and write the Features in Given- When-Then format
  28. 28. Confidential | Copyright © QAAgility Technologies Pvt Ltd Attributes of Good Feature document •Complete •Testable •Specific
  29. 29. Confidential | Copyright © QAAgility Technologies Pvt Ltd Thank You. ashish.mishra@qaagility.com in.linkedin.com/in/ash1shm/ www.agiletestingalliance.org www.qaagility.com

×