bdd using cucumber

29
BDD using Cucumber By Ashish Mishra

Upload: agile-testing-alliance

Post on 12-Jul-2015

433 views

Category:

Software


6 download

TRANSCRIPT

Page 1: Bdd using Cucumber

BDD using Cucumber

By Ashish Mishra

Page 2: Bdd using Cucumber

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

Page 3: Bdd using Cucumber

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.

Page 4: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Page 5: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Page 6: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Page 7: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Page 8: Bdd using Cucumber

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

Page 9: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Goal

• Introduce Cucumber tool for Behavioral Driven Development

Page 10: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

What is BDD

• Hint: It is not about Test Automation

Page 11: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Software – What can go wrong?

• Implementation Defects

• Requirement Defects

Page 12: Bdd using Cucumber

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

Page 13: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Requirements – often misunderstood

Page 14: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Scrum

US 1 and 2 US 3 US 1 ,2 ,3

Page 15: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

BDD

Business

•Domain driven design

Technology

• Test driven development

Page 16: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

describe the

behavior

of your software

in a very understandable

way

Page 17: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Cucumber

is

Ruby-based

BDD framework

Page 18: Bdd using Cucumber

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

Page 19: Bdd using Cucumber

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

Page 20: Bdd using Cucumber

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

Page 21: Bdd using Cucumber

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>

Page 22: Bdd using Cucumber

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

Page 23: Bdd using Cucumber

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

Page 24: Bdd using Cucumber

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

Page 25: Bdd using Cucumber

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]...

Page 26: Bdd using Cucumber

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 ...

Page 27: Bdd using Cucumber

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

Page 28: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Attributes of Good Feature document

• Complete

• Testable

• Specific

Page 29: Bdd using Cucumber

Confidential | Copyright © QAAgility Technologies Pvt Ltd

Thank You.

[email protected]

in.linkedin.com/in/ash1shm/

www.agiletestingalliance.org

www.qaagility.com