SlideShare una empresa de Scribd logo
1 de 24
Descargar para leer sin conexión
MC
Half-day Tutorials
Monday, April 30th, 2018
8:30 AM
Implement BDD with Cucumber and
SpecFlow
Presented by:
Mary Thorn
Ipreo
Brought to you by:
350 Corporate Way, Suite 400, Orange Park, FL 32073
888---268---8770 ·· 904---278---0524 - info@techwell.com - http://www.stareast.techwell.com/
Mary Thorn
Ipreo
Chief storyteller of The Three Pillars of Agile Testing and Quality, Mary Thorn is
director of agile practices at Ipreo in Raleigh, NC. Mary has a broad agile and
testing background that spans automation, data warehouses, and web-based
systems in a wide variety of technologies and testing techniques. During her
more than nineteen years of experience with healthcare, HR, financial, and SaaS-
based products, Mary has held manager- and contributor-level positions in
software development organizations. A strong leader in agile and testing
methodologies, Mary has direct experience leading teams through agile adoption
and beyond.
4/3/18
1
Identifier
Implement BDD
with Cucumber
or Specflow
Mary Thron
marythorn@gmail.com
What is the problem?
• Have you ever had overlooked requirements?
• Have you ever built the wrong thing?
• Do you have tangible reference materials?
• Have you ever interpreted a requirement incorrectly?
4/3/18
2
The Communication Problem
The Challenge:
● Today, the most difficult problem in software
development is knowing what to build, not how to build
it.
● Knowing what to build, requires knowing why it is being
built. In other words, understanding the goal.
The Communication Problem
The Problem:
▪ Stories typically concentrate on the what and the how, not the
why. Goals and examples are usually missing.
▪ Stories are usually a list of imperative requirements (acceptance
criteria).
▪ Imperative requirements are usually interpreted in subtly
different ways by each person. If goals and examples are
absent, misinterpretation is much more likely.
4/3/18
3
The Communication Problem
Example:
▪ Requirement: Draw a star with 10
points.
OR
The Communication Problem
Solution: Specification by Example
▪ People understand requirements best using
concrete examples.
▪ Examples clear up ambiguity and
misunderstandings.
▪ Examples expose missing requirements.
▪ Examples force everyone to think harder about
a problem.
4/3/18
4
The Communication Problem
Specification by Example
▪ This is the basis of acceptance testing and
Behavior Driven Design (BDD).
▪ It is critical that everyone participates in
creating the examples so that the
understanding is shared.
▪ Ultimately, acceptance testing is less about
the example itself and more about the
conversation required to create the example.
Simple picture
4/3/18
5
Simple Example
Acceptance Criteria: Transactions are
rounded to the nearest cent.
Original Value Rounded Value
$0.021
$0.025
$0.029
$0.02
$0.02
$0.02
Simple Example
Why was there confusion?
The goal was missing…
Goal: Create a currency conversion system.
The Concrete Example clarified what was meant by the
acceptance criteria.
Scenario Outline: Verify Transactions are rounded down to the
nearest cent.
Given I am on the order screen
When I make a <transaction> of values
Then the <values> are rounded
Examples:
|transaction|values|
|.021|.02|
|.025|.02|
|.029|.02|
4/3/18
6
Simple Example
▪ This simple example is a REAL EXAMPLE in a system
that was well-tested and approved by all parties.
▪ Attacker was able to steal > $15,000 starting with a
single cent using this process...
▪ $0.01 → 0.0051 € rounded to 0.01 €
▪ 0.01 € → $0.0196 rounded to $0.02
▪ A seemingly minor ambiguity in the requirements was
very expensive.
Take Aways
▪ Concrete examples drive understanding and
consensus.
▪ To create good representative examples,
everyone must understand the goal of the
story.
▪ For technical people to properly understand
the goal, they must understand the business
domain.
4/3/18
7
What does
Specflow have to
do with this?
Specflow IS THE
tool that helps
facilitate BDD
4/3/18
8
Automated Testing Process
Process:
▪ Product Owner writes the acceptance criteria and creates the
feature file per story.
▪ During grooming the team discusses the scenarios and asks
questions. Team can add/remove scenarios during grooming or
team updates feature file after.
▪ Feature file can be taken to planning to assist in task creation.
▪ Once Sprint has started QA and Dev work on getting the feature
file 90% complete before the developer starts coding.
▪ The developers code to the scenarios in the feature file, and
can do TDD if possible.
▪ QA expands the scenarios in the feature files after development
if there are new findings. Begins to automate in parallel with the
developer and do manual testing so they make it work in
parallel.
▪ When testing is complete PO acceptance is done by running the
acceptance tests.
Specflow Feature File
Feature File Overview:
l Written in plain text
l Define the test suite and contain the actual
tests which are called Scenarios
l Written collaboratively by everyone on the team
(PO, QA, and Dev)
l QA can run these manually.
4/3/18
9
Specflow Feature File
Feature:
l Suite is defined by keyword “Feature:” followed
by a description. This states the goal for the
Feature File. When the Feature File is complete,
a tag is included at this level so that all of the
test Scenarios contained within the file can be
run from a single command.
Feature: This tests the currency conversion
system
Specflow Feature Files
Background:
l “Background:” is run before each test so that
you don’t have to repeat steps. Equal to a setup
step.
Background:
Given I login with the test account
And I navigate to the Transaction Screen
Then I should see the Transaction logo
4/3/18
10
Specflow Feature Files
Scenario:
l Individual tests are defined by “Scenario:”
followed by a unique name. Scenarios are
concrete examples of how we want the
software to behave. The first line states the
goal of the given Scenario, while every line
thereafter lists the steps needed to complete
the test.
l Scenario: Verify Transactions are rounded
to the nearest cent.
Specflow Feature Files
Scenario Outline:
l “Scenario Outline:” is used for data driven tests.
Scenario Outline: Verify Transactions are rounded to the nearest cent.
Given I am on the order screen
When I make a <transaction> of values
Then the <values> are rounded
Examples:
|transaction|values|
|.021|.02|
|.025|.02|
|.029|.02|
4/3/18
11
Specflow Feature Files
Keywords:
• Tests have reserved words that begin each line:
Given, When, Then, And, But.
•Use Given to state a precondition
•Use When & And when taking an action
•Use Then when asserting a validation
Scenario: Verify Transactions are rounded to the nearest cent.
Given I am on the order screen
AND(GIVEN)
When I make a transaction of 9.025
And(WHEN) save the transaction
Then the value should equal 9.02
AND(THEN)
Specflow Feature Files
Tags:
• Tags a powerful tool to organize tests and
scenarios. A Scenario or feature can have as
many tags as you like. Just separate them with
spaces.
• A note to the wise: Keep it simple.
@tag @smoke_test @component
4/3/18
12
Imperative vs Declarative
è The imperative style uses highly reusable granular steps which outlines
much of the user interface.
Write tests in Declarative format
è Declarative style is more aligned with User Stories in the agile sense
having more of the "token for conversation" feel to it.
è The first thing that you should observe about this style is how much
smaller it is than the imperative one.
è The imperative style tends to produce noisy scenarios that drown out
the signal. With the declarative style the goal of the scenario remains
clear. When a new field is added to the form the scenario does not
have to be modified.
4/3/18
13
Shorter tests
è Shorter tests are better. Omit any details from the scenario
that are not necessary for the business scenario being
validated.
è BAD
è GOOD
Verify only one thing at a time
è Try to minimize each scenario and test one thing at a time
è Try to limit to 1 Given and 1 Then per scenario
BAD
Scenario: Test A
Given I login
When I goto the main screen
Then I can start
Given I have started
When I create x
Then it is verified
GOOD
Scenario: Verify that I can start
Given I have logged in
When I have started
Then it is verified
4/3/18
14
Max number of sentences 10
è Test scenarios should consist of 3 max 10 conditions.
BAD
GOOD
Scenarios must be independent.
è Scenario should run independently without any dependencies on other
scenarios.
BAD
Scenario: Test A
Given I login
When I goto the main screen
Then I can start
Scenario: Test B
Given I have started
When I create x
Then it is verified
GOOD
Scenario: Verify that I can start
Given I have logged in
When I have started
Then it is verified
4/3/18
15
Group related scenarios together in a
feature
è Related scenarios should be grouped together in
features.
Bad:
Feature: Verify you can post/edit/delete status update. Verify you
can change you account permissions of who can see me. Verify I
can create a facebook event. Verify I can create a facebook group.
Good:
Feature: Verify you can post/edit/delete status update. Verify you
can post/edit/delete a picture. Verify you can “checkin”
#TFS123, #TFS125
Cover both the happy and non-happy paths
è Scenarios should cover both happy and non-happy paths. A happy
path is a straightforward user journey while a non-happy path covers
different edge cases around the happy path, including invalid inputs etc.
HAPPY
UNHAPPY
4/3/18
16
Do NOT Hardcode configuration data
è Assume your test will run in all environments therefore
nothing should be hardcoded for a specific environment
BAD
Given I login to QX environment with user ‘mthorn’
GOOD
Given I login to environment ‘environment’ enter the user ‘user’
and the password ‘password’
Make sure Data Driven Tests are Readable
è No more than 5 columns and 10 rows for example, else
call in from Excel
BAD
Scenario outline: Free delivery Given the threshold for free delivery is 10 books And the customer is
<type> with <books> in the cart When checking out Then free delivery is <free delivery>
Examples
| type | books | free delivery |
| VIP | 9 | not offered |
| VIP | 10 | offered |
| VIP | 11 | offered |
| Normal | 10 | not offered |
| Normal | 9 | not offered |
| Normal | 10 | offered |
| VIP | 11 | offered |
| Normal | 10 | not offered |
| STD| 9 | not offered |
| STD | 10 | offered |
| STD | 11 | offered |
| Normal | 10 | not offered |
4/3/18
17
Don't include technical stuff in your sentences
è If it looks like a programmer wrote it then it’s wrong.
BAD:
Given group entity for the brand pid available in the PIPS datastore.
GOOD:
Given BBC TV brand is available to public or coming soon
Feature versus Scenario Hooks*
è A Tag placed on a Feature will apply to all Scenarios within
that Feature
è BeforeFeature and AfterFeature are “Feature only” Hooks.
Their corresponding Tags can only be placed before the
Feature keyword.
4/3/18
18
Tags
Keep It simple stupid
è Functional area
è CI run
• @smoke
• @sprint
• @regression
Hook Order*
BeforeTestRun
BeforeFeature
BeforeScenario or Before
BeforeScenarioBlock
BeforeStep
AfterStep
AfterScenarioBlock
AfterScenario or After
AfterFeature
AfterTestRun
4/3/18
19
Horizon – Real World Example
The Challenge:
How to effectively communicate
requirements to the team, to be
developed / tested / implemented while
exceeding business expectations
Story Title: As a Horizon User, I want to access a page with detailed application specific information so that I can learn
more about the Horizon's offerings
Description:
In lieu of creating an Information page (as detailed in HZN-6805), we will instead provide a link to open a new browser for the applications in Internet
Explorer, similar to how we will handle the news items. The application specific information pages contain a detailed summary of Horizon’s offerings and
serve as a Marketing tool for potential users. Ultimately, launching this page directly is a simpler and cheaper solution that building a new window.
Acceptance Tests:
1.) An "I" icon is shown on each application tile, in the All Apps
view. This icon is not displayed in the My Apps view.
2.) If I am entitled to an application and it is live in Production, or if
the application is coming soon, or if I am not entitled to it - then
clicking the “I” icon will open the info page for that application.
3.) If I am entitled to an application and it is live in Production, then
clicking anywhere else in the tile (ie: NOT on the "i" icon) will open
the application.
4.) If the application is coming soon, then the following message is
shown when they click anywhere else in the tile (ie: NOT on the "i"
icon):
This app is not available yet
Please select the info icon to view more information on the Risk
Intranet
5.) If the user is not entitled to the application, then the following
message is shown when they click anywhere else in the tile (ie: NOT
on the "i" icon):
You do not have access to view this app
Please select the info icon to view more information and request
access on the Risk Intranet
6.) If the application does not have an associated info page, then
clicking the “I” icon will open the Horizon home page
(http://risk.intranet.db.com/content/horizon_coo_30587.html)
7.) All scenarios from feature file have been implemented correctly.
4/3/18
20
Feature File
Example 1:
Verify clicking directly on the “I” icon launches a new internet
page when the user is permissioned to the application and it is
live in production
Given that I'm on the My Apps page
And I am permissioned to an application that is live in production
When I click the “I” icon on the application tile
Then a new browser window opens
Example 2:
Verify clicking directly on the “I” icon launches a new internet
page when the application is coming soon
Given that I'm on the My Apps page
And an application is coming soon
When I click the “I” icon on the application tile
Then a new browser window opens
And the All Apps page state is retained
Example 3:
Verify clicking in an area outside of the “I” icon (but within the tile)
launches the application when the user is permissioned to the
application and it is live in production
Given that I'm on the My Apps page
And I am permissioned to an application that is live in production
When I click on an area outside of the “I” icon, within the tile
Then the application opens
Benefits
▪ Clear Expectations Communicated
▪ Defined Scope
▪ Reveals Overlooked Requirements
▪ Tangible Reference Materials
▪ Accurate Story/Task Estimations
▪ Deliberate Collaboration Between QA/DEV/PO
▪ Increased Productivity
▪ Commitments are met (and often times exceeded!)
▪ Higher quality b/c everyone shares the same understanding of the requirements and builds it
right the first time.
▪ Tests become the system's regression suite.
▪ Create an objective verification of “done-ness” for a story. A story is done when all tests
pass.
▪ Create transparency into progress on a story.
▪ Manual testers are part of the automation process.
▪ Allows for more exploratory testing b/c happy path is automated
4/3/18
21
Brainstorming
www.google.com
Story Time
Story from Google.com
Card Template:
As a________________ I want to _____________So that __________
Acceptance Criteria:
- Verify that…..
201
0
42
4/3/18
4/3/18
22
Write the Acceptance Criteria
Keywords:
Tests have reserved words that begin each line:
Given, When, Then, And, But.
• Use Given to state a precondition
• Use When & And when taking an action
• Use Then when asserting a validation
Share
QUESTIONS?

Más contenido relacionado

La actualidad más candente

Git with bitbucket
Git with bitbucketGit with bitbucket
Git with bitbucket
Sumin Byeon
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 

La actualidad más candente (20)

Gitlab flow
Gitlab flowGitlab flow
Gitlab flow
 
GitOps Toolkit (Cloud Native Nordics Tech Talk)
GitOps Toolkit (Cloud Native Nordics Tech Talk)GitOps Toolkit (Cloud Native Nordics Tech Talk)
GitOps Toolkit (Cloud Native Nordics Tech Talk)
 
Git basic
Git basicGit basic
Git basic
 
Continuous Integration With Jenkins
Continuous Integration With JenkinsContinuous Integration With Jenkins
Continuous Integration With Jenkins
 
Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradle
 
Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-Flow
 
BitBucket presentation
BitBucket presentationBitBucket presentation
BitBucket presentation
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Cucumber presenation
Cucumber presenationCucumber presenation
Cucumber presenation
 
Git with bitbucket
Git with bitbucketGit with bitbucket
Git with bitbucket
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
DevOps with GitHub Actions
DevOps with GitHub ActionsDevOps with GitHub Actions
DevOps with GitHub Actions
 
CI/CD with Github Actions
CI/CD with Github ActionsCI/CD with Github Actions
CI/CD with Github Actions
 
BDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVABDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVA
 
GIT presentation
GIT presentationGIT presentation
GIT presentation
 
Learning git
Learning gitLearning git
Learning git
 
CI with Gitlab & Docker
CI with Gitlab & DockerCI with Gitlab & Docker
CI with Gitlab & Docker
 
git and github
git and githubgit and github
git and github
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
 
Jenkins Overview
Jenkins OverviewJenkins Overview
Jenkins Overview
 

Similar a Implement BDD with Cucumber and SpecFlow

Life cycle of user story: Outside-in agile product management & testing, or...
Life cycle of user story: Outside-in agile product management & testing, or...Life cycle of user story: Outside-in agile product management & testing, or...
Life cycle of user story: Outside-in agile product management & testing, or...
Ravi Tadwalkar
 

Similar a Implement BDD with Cucumber and SpecFlow (20)

Specification-by-Example: A Cucumber Implementation
Specification-by-Example: A Cucumber ImplementationSpecification-by-Example: A Cucumber Implementation
Specification-by-Example: A Cucumber Implementation
 
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
 
Testers in an agile world
Testers in an agile worldTesters in an agile world
Testers in an agile world
 
Acceptance And Story Testing Patterns - By Charles Bradley
Acceptance And Story Testing Patterns - By Charles BradleyAcceptance And Story Testing Patterns - By Charles Bradley
Acceptance And Story Testing Patterns - By Charles Bradley
 
Life cycle of user story: Outside-in agile product management & testing, or...
Life cycle of user story: Outside-in agile product management & testing, or...Life cycle of user story: Outside-in agile product management & testing, or...
Life cycle of user story: Outside-in agile product management & testing, or...
 
Writing test cases from user stories and acceptance criteria
Writing test cases from user stories and acceptance criteria Writing test cases from user stories and acceptance criteria
Writing test cases from user stories and acceptance criteria
 
B4 u solution_writing test cases from user stories and acceptance criteria
B4 u solution_writing test cases from user stories and acceptance criteriaB4 u solution_writing test cases from user stories and acceptance criteria
B4 u solution_writing test cases from user stories and acceptance criteria
 
Writing Test Cases From User Stories And Acceptance Criteria
Writing Test Cases From User Stories And Acceptance CriteriaWriting Test Cases From User Stories And Acceptance Criteria
Writing Test Cases From User Stories And Acceptance Criteria
 
Using Stories to Test Requirements and Systems
Using Stories to Test Requirements and SystemsUsing Stories to Test Requirements and Systems
Using Stories to Test Requirements and Systems
 
BDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and Selenium
 
Workshop: Behavior Driven Development - Deliver value by Naveen Kumar Singh
Workshop: Behavior Driven Development - Deliver value by Naveen Kumar SinghWorkshop: Behavior Driven Development - Deliver value by Naveen Kumar Singh
Workshop: Behavior Driven Development - Deliver value by Naveen Kumar Singh
 
Double Loop
Double LoopDouble Loop
Double Loop
 
Patterns for Collaboration: Toward Whole-Team Quality
Patterns for Collaboration: Toward Whole-Team QualityPatterns for Collaboration: Toward Whole-Team Quality
Patterns for Collaboration: Toward Whole-Team Quality
 
Sprinkle on Just Enough Process
Sprinkle on Just Enough ProcessSprinkle on Just Enough Process
Sprinkle on Just Enough Process
 
Conversion Conference 2011 NYC presentation
Conversion Conference 2011 NYC presentationConversion Conference 2011 NYC presentation
Conversion Conference 2011 NYC presentation
 
Seven Keys to Navigating Your Agile Testing Transition
Seven Keys to Navigating Your Agile Testing TransitionSeven Keys to Navigating Your Agile Testing Transition
Seven Keys to Navigating Your Agile Testing Transition
 
The Whole Story of The User Story
The Whole Story of The User StoryThe Whole Story of The User Story
The Whole Story of The User Story
 
Grails Worst Practices
Grails Worst PracticesGrails Worst Practices
Grails Worst Practices
 
ATDD And BDD The Great Beat Down…or…Debate
ATDD And BDD The Great Beat Down…or…DebateATDD And BDD The Great Beat Down…or…Debate
ATDD And BDD The Great Beat Down…or…Debate
 
Agile Testing Framework - The Art of Automated Testing
Agile Testing Framework - The Art of Automated TestingAgile Testing Framework - The Art of Automated Testing
Agile Testing Framework - The Art of Automated Testing
 

Más de TechWell

Más de TechWell (20)

Failing and Recovering
Failing and RecoveringFailing and Recovering
Failing and Recovering
 
Instill a DevOps Testing Culture in Your Team and Organization
Instill a DevOps Testing Culture in Your Team and Organization Instill a DevOps Testing Culture in Your Team and Organization
Instill a DevOps Testing Culture in Your Team and Organization
 
Test Design for Fully Automated Build Architecture
Test Design for Fully Automated Build ArchitectureTest Design for Fully Automated Build Architecture
Test Design for Fully Automated Build Architecture
 
System-Level Test Automation: Ensuring a Good Start
System-Level Test Automation: Ensuring a Good StartSystem-Level Test Automation: Ensuring a Good Start
System-Level Test Automation: Ensuring a Good Start
 
Build Your Mobile App Quality and Test Strategy
Build Your Mobile App Quality and Test StrategyBuild Your Mobile App Quality and Test Strategy
Build Your Mobile App Quality and Test Strategy
 
Testing Transformation: The Art and Science for Success
Testing Transformation: The Art and Science for SuccessTesting Transformation: The Art and Science for Success
Testing Transformation: The Art and Science for Success
 
Develop WebDriver Automated Tests—and Keep Your Sanity
Develop WebDriver Automated Tests—and Keep Your SanityDevelop WebDriver Automated Tests—and Keep Your Sanity
Develop WebDriver Automated Tests—and Keep Your Sanity
 
Ma 15
Ma 15Ma 15
Ma 15
 
Eliminate Cloud Waste with a Holistic DevOps Strategy
Eliminate Cloud Waste with a Holistic DevOps StrategyEliminate Cloud Waste with a Holistic DevOps Strategy
Eliminate Cloud Waste with a Holistic DevOps Strategy
 
Transform Test Organizations for the New World of DevOps
Transform Test Organizations for the New World of DevOpsTransform Test Organizations for the New World of DevOps
Transform Test Organizations for the New World of DevOps
 
The Fourth Constraint in Project Delivery—Leadership
The Fourth Constraint in Project Delivery—LeadershipThe Fourth Constraint in Project Delivery—Leadership
The Fourth Constraint in Project Delivery—Leadership
 
Resolve the Contradiction of Specialists within Agile Teams
Resolve the Contradiction of Specialists within Agile TeamsResolve the Contradiction of Specialists within Agile Teams
Resolve the Contradiction of Specialists within Agile Teams
 
Pin the Tail on the Metric: A Field-Tested Agile Game
Pin the Tail on the Metric: A Field-Tested Agile GamePin the Tail on the Metric: A Field-Tested Agile Game
Pin the Tail on the Metric: A Field-Tested Agile Game
 
Agile Performance Holarchy (APH)—A Model for Scaling Agile Teams
Agile Performance Holarchy (APH)—A Model for Scaling Agile TeamsAgile Performance Holarchy (APH)—A Model for Scaling Agile Teams
Agile Performance Holarchy (APH)—A Model for Scaling Agile Teams
 
A Business-First Approach to DevOps Implementation
A Business-First Approach to DevOps ImplementationA Business-First Approach to DevOps Implementation
A Business-First Approach to DevOps Implementation
 
Databases in a Continuous Integration/Delivery Process
Databases in a Continuous Integration/Delivery ProcessDatabases in a Continuous Integration/Delivery Process
Databases in a Continuous Integration/Delivery Process
 
Mobile Testing: What—and What Not—to Automate
Mobile Testing: What—and What Not—to AutomateMobile Testing: What—and What Not—to Automate
Mobile Testing: What—and What Not—to Automate
 
Cultural Intelligence: A Key Skill for Success
Cultural Intelligence: A Key Skill for SuccessCultural Intelligence: A Key Skill for Success
Cultural Intelligence: A Key Skill for Success
 
Turn the Lights On: A Power Utility Company's Agile Transformation
Turn the Lights On: A Power Utility Company's Agile TransformationTurn the Lights On: A Power Utility Company's Agile Transformation
Turn the Lights On: A Power Utility Company's Agile Transformation
 
Scale: The Most Hyped Term in Agile Development Today
Scale: The Most Hyped Term in Agile Development TodayScale: The Most Hyped Term in Agile Development Today
Scale: The Most Hyped Term in Agile Development Today
 

Último

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Último (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Implement BDD with Cucumber and SpecFlow

  • 1. MC Half-day Tutorials Monday, April 30th, 2018 8:30 AM Implement BDD with Cucumber and SpecFlow Presented by: Mary Thorn Ipreo Brought to you by: 350 Corporate Way, Suite 400, Orange Park, FL 32073 888---268---8770 ·· 904---278---0524 - info@techwell.com - http://www.stareast.techwell.com/
  • 2. Mary Thorn Ipreo Chief storyteller of The Three Pillars of Agile Testing and Quality, Mary Thorn is director of agile practices at Ipreo in Raleigh, NC. Mary has a broad agile and testing background that spans automation, data warehouses, and web-based systems in a wide variety of technologies and testing techniques. During her more than nineteen years of experience with healthcare, HR, financial, and SaaS- based products, Mary has held manager- and contributor-level positions in software development organizations. A strong leader in agile and testing methodologies, Mary has direct experience leading teams through agile adoption and beyond.
  • 3. 4/3/18 1 Identifier Implement BDD with Cucumber or Specflow Mary Thron marythorn@gmail.com What is the problem? • Have you ever had overlooked requirements? • Have you ever built the wrong thing? • Do you have tangible reference materials? • Have you ever interpreted a requirement incorrectly?
  • 4. 4/3/18 2 The Communication Problem The Challenge: ● Today, the most difficult problem in software development is knowing what to build, not how to build it. ● Knowing what to build, requires knowing why it is being built. In other words, understanding the goal. The Communication Problem The Problem: ▪ Stories typically concentrate on the what and the how, not the why. Goals and examples are usually missing. ▪ Stories are usually a list of imperative requirements (acceptance criteria). ▪ Imperative requirements are usually interpreted in subtly different ways by each person. If goals and examples are absent, misinterpretation is much more likely.
  • 5. 4/3/18 3 The Communication Problem Example: ▪ Requirement: Draw a star with 10 points. OR The Communication Problem Solution: Specification by Example ▪ People understand requirements best using concrete examples. ▪ Examples clear up ambiguity and misunderstandings. ▪ Examples expose missing requirements. ▪ Examples force everyone to think harder about a problem.
  • 6. 4/3/18 4 The Communication Problem Specification by Example ▪ This is the basis of acceptance testing and Behavior Driven Design (BDD). ▪ It is critical that everyone participates in creating the examples so that the understanding is shared. ▪ Ultimately, acceptance testing is less about the example itself and more about the conversation required to create the example. Simple picture
  • 7. 4/3/18 5 Simple Example Acceptance Criteria: Transactions are rounded to the nearest cent. Original Value Rounded Value $0.021 $0.025 $0.029 $0.02 $0.02 $0.02 Simple Example Why was there confusion? The goal was missing… Goal: Create a currency conversion system. The Concrete Example clarified what was meant by the acceptance criteria. Scenario Outline: Verify Transactions are rounded down to the nearest cent. Given I am on the order screen When I make a <transaction> of values Then the <values> are rounded Examples: |transaction|values| |.021|.02| |.025|.02| |.029|.02|
  • 8. 4/3/18 6 Simple Example ▪ This simple example is a REAL EXAMPLE in a system that was well-tested and approved by all parties. ▪ Attacker was able to steal > $15,000 starting with a single cent using this process... ▪ $0.01 → 0.0051 € rounded to 0.01 € ▪ 0.01 € → $0.0196 rounded to $0.02 ▪ A seemingly minor ambiguity in the requirements was very expensive. Take Aways ▪ Concrete examples drive understanding and consensus. ▪ To create good representative examples, everyone must understand the goal of the story. ▪ For technical people to properly understand the goal, they must understand the business domain.
  • 9. 4/3/18 7 What does Specflow have to do with this? Specflow IS THE tool that helps facilitate BDD
  • 10. 4/3/18 8 Automated Testing Process Process: ▪ Product Owner writes the acceptance criteria and creates the feature file per story. ▪ During grooming the team discusses the scenarios and asks questions. Team can add/remove scenarios during grooming or team updates feature file after. ▪ Feature file can be taken to planning to assist in task creation. ▪ Once Sprint has started QA and Dev work on getting the feature file 90% complete before the developer starts coding. ▪ The developers code to the scenarios in the feature file, and can do TDD if possible. ▪ QA expands the scenarios in the feature files after development if there are new findings. Begins to automate in parallel with the developer and do manual testing so they make it work in parallel. ▪ When testing is complete PO acceptance is done by running the acceptance tests. Specflow Feature File Feature File Overview: l Written in plain text l Define the test suite and contain the actual tests which are called Scenarios l Written collaboratively by everyone on the team (PO, QA, and Dev) l QA can run these manually.
  • 11. 4/3/18 9 Specflow Feature File Feature: l Suite is defined by keyword “Feature:” followed by a description. This states the goal for the Feature File. When the Feature File is complete, a tag is included at this level so that all of the test Scenarios contained within the file can be run from a single command. Feature: This tests the currency conversion system Specflow Feature Files Background: l “Background:” is run before each test so that you don’t have to repeat steps. Equal to a setup step. Background: Given I login with the test account And I navigate to the Transaction Screen Then I should see the Transaction logo
  • 12. 4/3/18 10 Specflow Feature Files Scenario: l Individual tests are defined by “Scenario:” followed by a unique name. Scenarios are concrete examples of how we want the software to behave. The first line states the goal of the given Scenario, while every line thereafter lists the steps needed to complete the test. l Scenario: Verify Transactions are rounded to the nearest cent. Specflow Feature Files Scenario Outline: l “Scenario Outline:” is used for data driven tests. Scenario Outline: Verify Transactions are rounded to the nearest cent. Given I am on the order screen When I make a <transaction> of values Then the <values> are rounded Examples: |transaction|values| |.021|.02| |.025|.02| |.029|.02|
  • 13. 4/3/18 11 Specflow Feature Files Keywords: • Tests have reserved words that begin each line: Given, When, Then, And, But. •Use Given to state a precondition •Use When & And when taking an action •Use Then when asserting a validation Scenario: Verify Transactions are rounded to the nearest cent. Given I am on the order screen AND(GIVEN) When I make a transaction of 9.025 And(WHEN) save the transaction Then the value should equal 9.02 AND(THEN) Specflow Feature Files Tags: • Tags a powerful tool to organize tests and scenarios. A Scenario or feature can have as many tags as you like. Just separate them with spaces. • A note to the wise: Keep it simple. @tag @smoke_test @component
  • 14. 4/3/18 12 Imperative vs Declarative è The imperative style uses highly reusable granular steps which outlines much of the user interface. Write tests in Declarative format è Declarative style is more aligned with User Stories in the agile sense having more of the "token for conversation" feel to it. è The first thing that you should observe about this style is how much smaller it is than the imperative one. è The imperative style tends to produce noisy scenarios that drown out the signal. With the declarative style the goal of the scenario remains clear. When a new field is added to the form the scenario does not have to be modified.
  • 15. 4/3/18 13 Shorter tests è Shorter tests are better. Omit any details from the scenario that are not necessary for the business scenario being validated. è BAD è GOOD Verify only one thing at a time è Try to minimize each scenario and test one thing at a time è Try to limit to 1 Given and 1 Then per scenario BAD Scenario: Test A Given I login When I goto the main screen Then I can start Given I have started When I create x Then it is verified GOOD Scenario: Verify that I can start Given I have logged in When I have started Then it is verified
  • 16. 4/3/18 14 Max number of sentences 10 è Test scenarios should consist of 3 max 10 conditions. BAD GOOD Scenarios must be independent. è Scenario should run independently without any dependencies on other scenarios. BAD Scenario: Test A Given I login When I goto the main screen Then I can start Scenario: Test B Given I have started When I create x Then it is verified GOOD Scenario: Verify that I can start Given I have logged in When I have started Then it is verified
  • 17. 4/3/18 15 Group related scenarios together in a feature è Related scenarios should be grouped together in features. Bad: Feature: Verify you can post/edit/delete status update. Verify you can change you account permissions of who can see me. Verify I can create a facebook event. Verify I can create a facebook group. Good: Feature: Verify you can post/edit/delete status update. Verify you can post/edit/delete a picture. Verify you can “checkin” #TFS123, #TFS125 Cover both the happy and non-happy paths è Scenarios should cover both happy and non-happy paths. A happy path is a straightforward user journey while a non-happy path covers different edge cases around the happy path, including invalid inputs etc. HAPPY UNHAPPY
  • 18. 4/3/18 16 Do NOT Hardcode configuration data è Assume your test will run in all environments therefore nothing should be hardcoded for a specific environment BAD Given I login to QX environment with user ‘mthorn’ GOOD Given I login to environment ‘environment’ enter the user ‘user’ and the password ‘password’ Make sure Data Driven Tests are Readable è No more than 5 columns and 10 rows for example, else call in from Excel BAD Scenario outline: Free delivery Given the threshold for free delivery is 10 books And the customer is <type> with <books> in the cart When checking out Then free delivery is <free delivery> Examples | type | books | free delivery | | VIP | 9 | not offered | | VIP | 10 | offered | | VIP | 11 | offered | | Normal | 10 | not offered | | Normal | 9 | not offered | | Normal | 10 | offered | | VIP | 11 | offered | | Normal | 10 | not offered | | STD| 9 | not offered | | STD | 10 | offered | | STD | 11 | offered | | Normal | 10 | not offered |
  • 19. 4/3/18 17 Don't include technical stuff in your sentences è If it looks like a programmer wrote it then it’s wrong. BAD: Given group entity for the brand pid available in the PIPS datastore. GOOD: Given BBC TV brand is available to public or coming soon Feature versus Scenario Hooks* è A Tag placed on a Feature will apply to all Scenarios within that Feature è BeforeFeature and AfterFeature are “Feature only” Hooks. Their corresponding Tags can only be placed before the Feature keyword.
  • 20. 4/3/18 18 Tags Keep It simple stupid è Functional area è CI run • @smoke • @sprint • @regression Hook Order* BeforeTestRun BeforeFeature BeforeScenario or Before BeforeScenarioBlock BeforeStep AfterStep AfterScenarioBlock AfterScenario or After AfterFeature AfterTestRun
  • 21. 4/3/18 19 Horizon – Real World Example The Challenge: How to effectively communicate requirements to the team, to be developed / tested / implemented while exceeding business expectations Story Title: As a Horizon User, I want to access a page with detailed application specific information so that I can learn more about the Horizon's offerings Description: In lieu of creating an Information page (as detailed in HZN-6805), we will instead provide a link to open a new browser for the applications in Internet Explorer, similar to how we will handle the news items. The application specific information pages contain a detailed summary of Horizon’s offerings and serve as a Marketing tool for potential users. Ultimately, launching this page directly is a simpler and cheaper solution that building a new window. Acceptance Tests: 1.) An "I" icon is shown on each application tile, in the All Apps view. This icon is not displayed in the My Apps view. 2.) If I am entitled to an application and it is live in Production, or if the application is coming soon, or if I am not entitled to it - then clicking the “I” icon will open the info page for that application. 3.) If I am entitled to an application and it is live in Production, then clicking anywhere else in the tile (ie: NOT on the "i" icon) will open the application. 4.) If the application is coming soon, then the following message is shown when they click anywhere else in the tile (ie: NOT on the "i" icon): This app is not available yet Please select the info icon to view more information on the Risk Intranet 5.) If the user is not entitled to the application, then the following message is shown when they click anywhere else in the tile (ie: NOT on the "i" icon): You do not have access to view this app Please select the info icon to view more information and request access on the Risk Intranet 6.) If the application does not have an associated info page, then clicking the “I” icon will open the Horizon home page (http://risk.intranet.db.com/content/horizon_coo_30587.html) 7.) All scenarios from feature file have been implemented correctly.
  • 22. 4/3/18 20 Feature File Example 1: Verify clicking directly on the “I” icon launches a new internet page when the user is permissioned to the application and it is live in production Given that I'm on the My Apps page And I am permissioned to an application that is live in production When I click the “I” icon on the application tile Then a new browser window opens Example 2: Verify clicking directly on the “I” icon launches a new internet page when the application is coming soon Given that I'm on the My Apps page And an application is coming soon When I click the “I” icon on the application tile Then a new browser window opens And the All Apps page state is retained Example 3: Verify clicking in an area outside of the “I” icon (but within the tile) launches the application when the user is permissioned to the application and it is live in production Given that I'm on the My Apps page And I am permissioned to an application that is live in production When I click on an area outside of the “I” icon, within the tile Then the application opens Benefits ▪ Clear Expectations Communicated ▪ Defined Scope ▪ Reveals Overlooked Requirements ▪ Tangible Reference Materials ▪ Accurate Story/Task Estimations ▪ Deliberate Collaboration Between QA/DEV/PO ▪ Increased Productivity ▪ Commitments are met (and often times exceeded!) ▪ Higher quality b/c everyone shares the same understanding of the requirements and builds it right the first time. ▪ Tests become the system's regression suite. ▪ Create an objective verification of “done-ness” for a story. A story is done when all tests pass. ▪ Create transparency into progress on a story. ▪ Manual testers are part of the automation process. ▪ Allows for more exploratory testing b/c happy path is automated
  • 23. 4/3/18 21 Brainstorming www.google.com Story Time Story from Google.com Card Template: As a________________ I want to _____________So that __________ Acceptance Criteria: - Verify that….. 201 0 42 4/3/18
  • 24. 4/3/18 22 Write the Acceptance Criteria Keywords: Tests have reserved words that begin each line: Given, When, Then, And, But. • Use Given to state a precondition • Use When & And when taking an action • Use Then when asserting a validation Share QUESTIONS?