Scaffolding a
legacy app
with BDD scenarios
using SpecFlow/Cucumber
Agile in the City Bristol 2017
2nd November, 2017
Gáspár Nagy
coach • trainer • bdd addict • creator of specflow
“The BDD Books: Discovery” • http://bddbooks.com
@gasparnagy • gaspar@specsolutions.eu
Copyright © Gaspar NagyCopyright © Gaspar Nagy
bdd addict
given.when.then
CAUTION!
on the stage
Gáspár Nagy
coach, trainer and bdd addict
creator of SpecFlow
gaspar@specsolutions.eu
https://specsolutions.eu
@gasparnagy
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Check out our new book!
• A BDD book for everyone (PO, BA, dev,
tester)
• Practical guide
• Demonstrates good collaboration
techniques, illustrated by concrete
examples
Find it on Leanpub through
http://bddbooks.com!
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Agenda
• BDD, how I see it
• Challenges of legacy apps
• Concept of scaffolding through an example
• Fixing a bug & placing it on the testing pyramid
Copyright © Gaspar NagyCopyright © Gaspar Nagy
What is BDD?
Copyright © Gaspar NagyCopyright © Gaspar Nagy
[HttpPost]
public ActionResult Answer(int answer)
{
TriviaEntities db = new TriviaEntities();
var question = db.FindQuestion(CurrentQuestion);
if (question.Type == QuestionType.Easy)
{
db.AddScore(question, user, 10);
}
else
{
db.AddScore(question, user, 50);
}
var model = new GameModel
{ Score = db.GetScore(question, user) };
return View(model);
}
implement
feedback
Agile mini-waterfall
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Examples link requirements to software
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Scenario: Correct easy answer scores 10
Given I register a team
When I submit a correct easy answer
Then my score should be 10
Discovery
Automation with
Cucumber/SpecFlow
Examples link requirements to software
Formulation
Copyright © Gaspar NagyCopyright © Gaspar Nagy
So, what is BDD?
Discovery
Shared understanding is established through
collaboration and structured conversations
Formulation
Examples of system behaviour are documented
as scenarios
Automation
Scenarios are automated to be able to verify the
system’s behaviour
Copyright © Gaspar NagyCopyright © Gaspar Nagy
BDD “drives” development
Passing
scenario
Failing
scenario
Refactor
Copyright © Gaspar NagyCopyright © Gaspar Nagy
The TDD Cycle
GreenRed
Refactor
Copyright © Gaspar NagyCopyright © Gaspar Nagy
How can I apply this
to legacy apps?
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Working with a legacy app is like renovating a house…
Renovation can be challenging…
Source: http://kadarkocka.blogspot.com/2011_08_01_archive.html
Copyright © Gaspar NagyCopyright © Gaspar Nagy
My Story
The project was delivered in cooperation with TechTalk (www.techtalk.at)
My legacy app project…
Source: http://irodahaz.info
Complex domain…
106 failing (integration?) tests
Copyright © Gaspar NagyCopyright © Gaspar Nagy
… and other challenges
• 17 GB test database
• 46 projects
• 300k lines of code
• >2 minutes build time
Copyright © Gaspar NagyCopyright © Gaspar Nagy
What can I do with this?
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Source: Wikipedia
Copyright © Gaspar NagyCopyright © Gaspar Nagy
The first change request
Deployment –
Workflow
Change request
Source: http://irodahaz.info
We need to replace
that window up
there!
0. Get the infrastructure ready
Source: http://hfsaustralia.com.au/storage.html
Copyright © Gaspar NagyCopyright © Gaspar Nagy
0. Get the infrastructure ready
We need a healthy local dev and CI environment!
• Make a dummy test and get it running!
• Setup the desired testing model
(e.g. SpecFlow)
• Automated the scenario to exercise
the app with it’s dependencies (e.g.
database)
• Ignore/skip/delete unstable tests
Copyright © Gaspar NagyCopyright © Gaspar Nagy
1. Capture current behavior
• Based on the way it was explained by the client
• We did not worry about automation
• We did worry about details
Copyright © Gaspar NagyCopyright © Gaspar Nagy
The TDD Cycle
GreenRed
Refactor
Copyright © Gaspar NagyCopyright © Gaspar Nagy
1. Capture current behavior
Red
Copyright © Gaspar NagyCopyright © Gaspar Nagy
2. Automate “Then” steps
• Feel free to hard-wire concrete data (IDs)!
Red
Copyright © Gaspar NagyCopyright © Gaspar Nagy
3. Automate “When”
with hard-wired data
• We have something to start with!
• (But its obviously nasty with “2347599”)
Green
Copyright © Gaspar NagyCopyright © Gaspar Nagy
It’s passing, although
we haven’t done
anything for the
“Given”…
We’ve got a scaffolding!
Source: Wikipedia
Copyright © Gaspar NagyCopyright © Gaspar Nagy
We need to get rid of the hard-wired data!
1
2
3
4
5
8
9
#6
7
Remove a bit of scaffolding
4. Pick off a bite!
1
2
3
4
5
8
9
#6
7
Aut
#
#’
Copyright © Gaspar NagyCopyright © Gaspar Nagy
4. Pick off a bite
Refactor
Copyright © Gaspar NagyCopyright © Gaspar Nagy
We have a test now
for the current
behavior…
Let’s implement the
feature!
Copyright © Gaspar NagyCopyright © Gaspar Nagy
We have scaffolded our application for
implementing this feature!
Copyright © Gaspar NagyCopyright © Gaspar Nagy
5. Describe an example of the new feature
Red
Copyright © Gaspar NagyCopyright © Gaspar Nagy
6. Automate and implement it!
• You can even forget that your are maintaining a legacy app here…
Green
Copyright © Gaspar NagyCopyright © Gaspar Nagy
GreenRed
Refactor
We not only made it, but…
• We established a CI/CD
pipeline
• We cleared out a
misunderstanding before
implementing the change
• We created a few reusable
automation steps
Copyright © Gaspar NagyCopyright © Gaspar Nagy
BDD for implementing a change request
• We addressed the system through a new feature
• Ensured that the test infrastructure works
• Scaffolded the app with a test for the current behavior using hard wired data
• Refactored the automation to eliminate some parts of these data – taken apart a
bit of the scaffolding
• Described and implemented the new feature
• Used the automation infrastructure for adding further tests
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Let’s fix a bug!
Copyright © Gaspar NagyCopyright © Gaspar Nagy
The first bug
Copyright © Gaspar NagyCopyright © Gaspar Nagy
GreenRed
Refactor
We not only made it, but…
• We isolated the issue
• We solved a testing challenge that was
even a problem for manual testing
• We covered another area of the
application with tests
• We created again a few more reusable
automation steps
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Shall we keep
this scenario?
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Shall we keep this scenario?
• Special context
• The app gets to an inconsistent
state (workflow stopped, script
running)
• The bug was in the SSH library
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Pic: http://gasparnagy.com/2017/02/balancing-scenarios-and-unit-tests-case-study-with-specflow/
Timeout
Scenario
Copyright © Gaspar NagyCopyright © Gaspar Nagy
A classification of quality aspects
Functional
• Works as
expected
• Expectations
are good
• Expectations
are
documented
Usability
• Secure
• Fast
• Convenient
• Pretty
• Consistent
• Predictable
Strategic
• Architecture
• Code quality
• Easy to
integrate
• Flexible
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Pic: http://gasparnagy.com/2017/02/balancing-scenarios-and-unit-tests-case-study-with-specflow/
Timeout
Scenario
Srv-UI Functional
Usability
Strategic
Edge
case
Argument
check
Timeout
Test
Happy
Path
Func1
Func2
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Functional
Usability
Strategic
Forrás: http://gasparnagy.com/2017/02/balancing-scenarios-and-unit-tests-case-study-with-specflow/
Happy
path
Srv-UI
Edge
case
Argument
check
Ext call
timeout
Func1
Func2
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Srv-UI
Functional
Usability
Strategic
Edge
case
Argument
check
Ext call
timeout
Forrás: http://gasparnagy.com/2017/02/balancing-scenarios-and-unit-tests-case-study-with-specflow/
Happy
Path
Func1
Func2
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Shall we keep regression tests?
• It depends…
• If the bug highlighted an important business case – keep it!
• If it described a special situation – delete it!
• And cover the root cause with technical tests
• Maintaining regression scenarios is costly!
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Working on a legacy app does not mean that you
cannot apply BDD process.
The scenarios can guide you to discover more and
more from the application!
As you learn more, the scaffolding can be removed…
Copyright © Gaspar NagyCopyright © Gaspar Nagy
Happy maintenance!
Gáspár Nagy
coach • trainer • bdd addict • creator of specflow
@gasparnagy • gaspar@specsolutions.eu
Thank you!
http://bddbooks.com

More Related Content

PDF
We are sinking: Hitting the testing iceberg (CukenFest London, 2018)
PDF
Continuous Behavior - BDD in Continuous Delivery (CoDers Who Test, Gothenburg...
PDF
BDD Scenarios in a Testing & Traceability Strategy (Webinar 19/02/2021)
PPTX
Legacy On Premise Apps Got You Down? No Problem - DevOps for All
PDF
MesosCon Asia Keynote: Replacing a Jet Engine Mid-flight
PDF
Canary Analyze All The Things: How We Learned to Keep Calm and Release Often
PPTX
Cloudstack Continuous Delivery
PPTX
DevOps Pipelines and Metrics Driven Feedback Loops
We are sinking: Hitting the testing iceberg (CukenFest London, 2018)
Continuous Behavior - BDD in Continuous Delivery (CoDers Who Test, Gothenburg...
BDD Scenarios in a Testing & Traceability Strategy (Webinar 19/02/2021)
Legacy On Premise Apps Got You Down? No Problem - DevOps for All
MesosCon Asia Keynote: Replacing a Jet Engine Mid-flight
Canary Analyze All The Things: How We Learned to Keep Calm and Release Often
Cloudstack Continuous Delivery
DevOps Pipelines and Metrics Driven Feedback Loops

What's hot (20)

PPTX
Canary releases & Blue green deployment
PDF
Building Autonomous Operations for Kubernetes with keptn
PDF
Continuous Integration Testing: Fully test your microservices application, ea...
PPTX
Continuous integration testing 2019 08
PPTX
Performance Metrics Driven CI/CD - Introduction to Continuous Innovation and ...
PPTX
Boston DevOps Days 2016: Implementing Metrics Driven DevOps - Why and How
PDF
Importance of GCP: 30 Days of GCP
PPTX
HOW TO OPTIMIZE NON-CODING TIME, ORI KEREN, LinearB
PDF
Making operations visible - devopsdays tokyo 2013
PPTX
DOES16 San Francisco - David Blank-Edelman - Lessons Learned from a Parallel ...
PPTX
AWS Summit - Trends in Advanced Monitoring for AWS environments
PPTX
DOES SFO 2016 - Scott Willson - Top 10 Ways to Fail at DevOps
PDF
Cloud Spin - building a photo booth with the Google Cloud Platform
PDF
Supercharge your app with Cloud Functions for Firebase
PPTX
Beginning Laravel Workshop - September 2018
PDF
GitHub Integration for Orangescrum Cloud Released!
PDF
Where should I run my code? Serverless, Containers, Virtual Machines and more
PPTX
A Guide to Event-Driven SRE-inspired DevOps
PPTX
Applying AI to Performance Engineering: Shift-Left, Shift-Right, Self-Healing
PPTX
Continuous Delivery and Automated Operations on k8s with keptn
Canary releases & Blue green deployment
Building Autonomous Operations for Kubernetes with keptn
Continuous Integration Testing: Fully test your microservices application, ea...
Continuous integration testing 2019 08
Performance Metrics Driven CI/CD - Introduction to Continuous Innovation and ...
Boston DevOps Days 2016: Implementing Metrics Driven DevOps - Why and How
Importance of GCP: 30 Days of GCP
HOW TO OPTIMIZE NON-CODING TIME, ORI KEREN, LinearB
Making operations visible - devopsdays tokyo 2013
DOES16 San Francisco - David Blank-Edelman - Lessons Learned from a Parallel ...
AWS Summit - Trends in Advanced Monitoring for AWS environments
DOES SFO 2016 - Scott Willson - Top 10 Ways to Fail at DevOps
Cloud Spin - building a photo booth with the Google Cloud Platform
Supercharge your app with Cloud Functions for Firebase
Beginning Laravel Workshop - September 2018
GitHub Integration for Orangescrum Cloud Released!
Where should I run my code? Serverless, Containers, Virtual Machines and more
A Guide to Event-Driven SRE-inspired DevOps
Applying AI to Performance Engineering: Shift-Left, Shift-Right, Self-Healing
Continuous Delivery and Automated Operations on k8s with keptn
Ad

Similar to Scaffolding a legacy app with BDD scenario (Agile in the City Bristol 2017) (20)

PDF
Scaffolding a legacy app with BDD scenarios using SpecFlow/Cucumber (HUSTEF 2...
PDF
Scaffolding a legacy app with BDD scenarios using SpecFlow/Cucumber (BDD Lond...
PDF
Introducing BDD to Legacy Applications with SpecFlow/Cucumber (Agilia Confere...
PPTX
Generative Testing in Clojure
PDF
Reengineering Legacy Software Chris Birchall
PPTX
The bigrewrite
PDF
The bigrewrite
ODP
Dealing With Legacy: The Real-World Experience
PPTX
Testing in Legacy: from Rags to Riches by Taras Slipets
PPTX
Testing in Legacy: From Rags to Riches
PDF
Flavius Ștef: Big Rewrites Without Big Risks at I T.A.K.E. Unconference
PDF
Big rewrites without big risks
PPTX
Novelty in Non-Greenfield
PDF
Unit testing legacy code
PDF
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
PPTX
Road to Continuous Delivery - Wix.com
PDF
Tackling Legacy Code November 2015
PPT
How engineering practices help business
PPTX
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
PPTX
Refactoring
Scaffolding a legacy app with BDD scenarios using SpecFlow/Cucumber (HUSTEF 2...
Scaffolding a legacy app with BDD scenarios using SpecFlow/Cucumber (BDD Lond...
Introducing BDD to Legacy Applications with SpecFlow/Cucumber (Agilia Confere...
Generative Testing in Clojure
Reengineering Legacy Software Chris Birchall
The bigrewrite
The bigrewrite
Dealing With Legacy: The Real-World Experience
Testing in Legacy: from Rags to Riches by Taras Slipets
Testing in Legacy: From Rags to Riches
Flavius Ștef: Big Rewrites Without Big Risks at I T.A.K.E. Unconference
Big rewrites without big risks
Novelty in Non-Greenfield
Unit testing legacy code
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
Road to Continuous Delivery - Wix.com
Tackling Legacy Code November 2015
How engineering practices help business
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
Refactoring
Ad

More from Gáspár Nagy (14)

PDF
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
PDF
BDD Scenarios in a Testing Strategy
PDF
Ramp up your testing solution, ExpoQA 2023
PDF
Fighting against technical debt (CukenFest 2020)
PDF
Süllyedünk! Ütközés a tesztelési jégheggyel (Teszt & Tea Meeup Budapest, 2018...
PDF
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
PDF
Testing is Difficult (Agile in the City Bristol 2017, Lightening talk)
PDF
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (Qualit...
PDF
A tesztelés szerepe folyamatos kihelyezést használó projektekben (Microsoft, ...
PDF
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
PDF
Property Based BDD Examples (ETSI UCAAT 2016, Budapest)
PDF
Given/When/Then-ready sprint planning with Example Mapping (Agilia Budapest 2...
PDF
Folyamatos integráció és kódépítés (ALM Day Budapest, 24/11/2015, Hungarian)
PDF
Given/When/Then-ready sprint planning (Agile Tour Vienna 2015)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
BDD Scenarios in a Testing Strategy
Ramp up your testing solution, ExpoQA 2023
Fighting against technical debt (CukenFest 2020)
Süllyedünk! Ütközés a tesztelési jégheggyel (Teszt & Tea Meeup Budapest, 2018...
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Testing is Difficult (Agile in the City Bristol 2017, Lightening talk)
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (Qualit...
A tesztelés szerepe folyamatos kihelyezést használó projektekben (Microsoft, ...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Property Based BDD Examples (ETSI UCAAT 2016, Budapest)
Given/When/Then-ready sprint planning with Example Mapping (Agilia Budapest 2...
Folyamatos integráció és kódépítés (ALM Day Budapest, 24/11/2015, Hungarian)
Given/When/Then-ready sprint planning (Agile Tour Vienna 2015)

Recently uploaded (20)

PPTX
HackYourBrain__UtrechtJUG__11092025.pptx
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PDF
Website Design & Development_ Professional Web Design Services.pdf
PDF
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
PPTX
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
PPTX
Computer Software - Technology and Livelihood Education
PPT
3.Software Design for software engineering
PPTX
ROI from Efficient Content & Campaign Management in the Digital Media Industry
PDF
infoteam HELLAS company profile 2025 presentation
PDF
BoxLang Dynamic AWS Lambda - Japan Edition
PDF
Sun and Bloombase Spitfire StoreSafe End-to-end Storage Security Solution
PPTX
R-Studio Crack Free Download 2025 Latest
PDF
What Makes a Great Data Visualization Consulting Service.pdf
PDF
Workplace Software and Skills - OpenStax
PPTX
string python Python Strings: Literals, Slicing, Methods, Formatting, and Pra...
PPTX
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
PPTX
Airline CRS | Airline CRS Systems | CRS System
PPTX
Download Adobe Photoshop Crack 2025 Free
PDF
CapCut PRO for PC Crack New Download (Fully Activated 2025)
PPTX
Chapter 1 - Transaction Processing and Mgt.pptx
HackYourBrain__UtrechtJUG__11092025.pptx
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
Website Design & Development_ Professional Web Design Services.pdf
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
Computer Software - Technology and Livelihood Education
3.Software Design for software engineering
ROI from Efficient Content & Campaign Management in the Digital Media Industry
infoteam HELLAS company profile 2025 presentation
BoxLang Dynamic AWS Lambda - Japan Edition
Sun and Bloombase Spitfire StoreSafe End-to-end Storage Security Solution
R-Studio Crack Free Download 2025 Latest
What Makes a Great Data Visualization Consulting Service.pdf
Workplace Software and Skills - OpenStax
string python Python Strings: Literals, Slicing, Methods, Formatting, and Pra...
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
Airline CRS | Airline CRS Systems | CRS System
Download Adobe Photoshop Crack 2025 Free
CapCut PRO for PC Crack New Download (Fully Activated 2025)
Chapter 1 - Transaction Processing and Mgt.pptx

Scaffolding a legacy app with BDD scenario (Agile in the City Bristol 2017)

  • 1. Scaffolding a legacy app with BDD scenarios using SpecFlow/Cucumber Agile in the City Bristol 2017 2nd November, 2017 Gáspár Nagy coach • trainer • bdd addict • creator of specflow “The BDD Books: Discovery” • http://bddbooks.com @gasparnagy • [email protected]
  • 2. Copyright © Gaspar NagyCopyright © Gaspar Nagy bdd addict given.when.then CAUTION! on the stage Gáspár Nagy coach, trainer and bdd addict creator of SpecFlow [email protected] https://specsolutions.eu @gasparnagy
  • 3. Copyright © Gaspar NagyCopyright © Gaspar Nagy Check out our new book! • A BDD book for everyone (PO, BA, dev, tester) • Practical guide • Demonstrates good collaboration techniques, illustrated by concrete examples Find it on Leanpub through http://bddbooks.com!
  • 4. Copyright © Gaspar NagyCopyright © Gaspar Nagy Agenda • BDD, how I see it • Challenges of legacy apps • Concept of scaffolding through an example • Fixing a bug & placing it on the testing pyramid
  • 5. Copyright © Gaspar NagyCopyright © Gaspar Nagy What is BDD?
  • 6. Copyright © Gaspar NagyCopyright © Gaspar Nagy [HttpPost] public ActionResult Answer(int answer) { TriviaEntities db = new TriviaEntities(); var question = db.FindQuestion(CurrentQuestion); if (question.Type == QuestionType.Easy) { db.AddScore(question, user, 10); } else { db.AddScore(question, user, 50); } var model = new GameModel { Score = db.GetScore(question, user) }; return View(model); } implement feedback Agile mini-waterfall
  • 7. Copyright © Gaspar NagyCopyright © Gaspar Nagy Examples link requirements to software
  • 8. Copyright © Gaspar NagyCopyright © Gaspar Nagy Scenario: Correct easy answer scores 10 Given I register a team When I submit a correct easy answer Then my score should be 10 Discovery Automation with Cucumber/SpecFlow Examples link requirements to software Formulation
  • 9. Copyright © Gaspar NagyCopyright © Gaspar Nagy So, what is BDD? Discovery Shared understanding is established through collaboration and structured conversations Formulation Examples of system behaviour are documented as scenarios Automation Scenarios are automated to be able to verify the system’s behaviour
  • 10. Copyright © Gaspar NagyCopyright © Gaspar Nagy BDD “drives” development Passing scenario Failing scenario Refactor
  • 11. Copyright © Gaspar NagyCopyright © Gaspar Nagy The TDD Cycle GreenRed Refactor
  • 12. Copyright © Gaspar NagyCopyright © Gaspar Nagy How can I apply this to legacy apps?
  • 13. Copyright © Gaspar NagyCopyright © Gaspar Nagy Working with a legacy app is like renovating a house…
  • 14. Renovation can be challenging… Source: http://kadarkocka.blogspot.com/2011_08_01_archive.html
  • 15. Copyright © Gaspar NagyCopyright © Gaspar Nagy My Story The project was delivered in cooperation with TechTalk (www.techtalk.at)
  • 16. My legacy app project… Source: http://irodahaz.info
  • 19. Copyright © Gaspar NagyCopyright © Gaspar Nagy … and other challenges • 17 GB test database • 46 projects • 300k lines of code • >2 minutes build time
  • 20. Copyright © Gaspar NagyCopyright © Gaspar Nagy What can I do with this?
  • 21. Copyright © Gaspar NagyCopyright © Gaspar Nagy
  • 23. Copyright © Gaspar NagyCopyright © Gaspar Nagy The first change request
  • 26. 0. Get the infrastructure ready Source: http://hfsaustralia.com.au/storage.html
  • 27. Copyright © Gaspar NagyCopyright © Gaspar Nagy 0. Get the infrastructure ready We need a healthy local dev and CI environment! • Make a dummy test and get it running! • Setup the desired testing model (e.g. SpecFlow) • Automated the scenario to exercise the app with it’s dependencies (e.g. database) • Ignore/skip/delete unstable tests
  • 28. Copyright © Gaspar NagyCopyright © Gaspar Nagy 1. Capture current behavior • Based on the way it was explained by the client • We did not worry about automation • We did worry about details
  • 29. Copyright © Gaspar NagyCopyright © Gaspar Nagy The TDD Cycle GreenRed Refactor
  • 30. Copyright © Gaspar NagyCopyright © Gaspar Nagy 1. Capture current behavior Red
  • 31. Copyright © Gaspar NagyCopyright © Gaspar Nagy 2. Automate “Then” steps • Feel free to hard-wire concrete data (IDs)! Red
  • 32. Copyright © Gaspar NagyCopyright © Gaspar Nagy 3. Automate “When” with hard-wired data • We have something to start with! • (But its obviously nasty with “2347599”) Green
  • 33. Copyright © Gaspar NagyCopyright © Gaspar Nagy It’s passing, although we haven’t done anything for the “Given”…
  • 34. We’ve got a scaffolding! Source: Wikipedia
  • 35. Copyright © Gaspar NagyCopyright © Gaspar Nagy We need to get rid of the hard-wired data!
  • 37. Remove a bit of scaffolding
  • 38. 4. Pick off a bite! 1 2 3 4 5 8 9 #6 7 Aut # #’
  • 39. Copyright © Gaspar NagyCopyright © Gaspar Nagy 4. Pick off a bite Refactor
  • 40. Copyright © Gaspar NagyCopyright © Gaspar Nagy We have a test now for the current behavior… Let’s implement the feature!
  • 41. Copyright © Gaspar NagyCopyright © Gaspar Nagy We have scaffolded our application for implementing this feature!
  • 42. Copyright © Gaspar NagyCopyright © Gaspar Nagy 5. Describe an example of the new feature Red
  • 43. Copyright © Gaspar NagyCopyright © Gaspar Nagy 6. Automate and implement it! • You can even forget that your are maintaining a legacy app here… Green
  • 44. Copyright © Gaspar NagyCopyright © Gaspar Nagy GreenRed Refactor We not only made it, but… • We established a CI/CD pipeline • We cleared out a misunderstanding before implementing the change • We created a few reusable automation steps
  • 45. Copyright © Gaspar NagyCopyright © Gaspar Nagy BDD for implementing a change request • We addressed the system through a new feature • Ensured that the test infrastructure works • Scaffolded the app with a test for the current behavior using hard wired data • Refactored the automation to eliminate some parts of these data – taken apart a bit of the scaffolding • Described and implemented the new feature • Used the automation infrastructure for adding further tests
  • 46. Copyright © Gaspar NagyCopyright © Gaspar Nagy Let’s fix a bug!
  • 47. Copyright © Gaspar NagyCopyright © Gaspar Nagy The first bug
  • 48. Copyright © Gaspar NagyCopyright © Gaspar Nagy GreenRed Refactor We not only made it, but… • We isolated the issue • We solved a testing challenge that was even a problem for manual testing • We covered another area of the application with tests • We created again a few more reusable automation steps
  • 49. Copyright © Gaspar NagyCopyright © Gaspar Nagy Shall we keep this scenario?
  • 50. Copyright © Gaspar NagyCopyright © Gaspar Nagy Shall we keep this scenario? • Special context • The app gets to an inconsistent state (workflow stopped, script running) • The bug was in the SSH library
  • 51. Copyright © Gaspar NagyCopyright © Gaspar Nagy Pic: http://gasparnagy.com/2017/02/balancing-scenarios-and-unit-tests-case-study-with-specflow/ Timeout Scenario
  • 52. Copyright © Gaspar NagyCopyright © Gaspar Nagy A classification of quality aspects Functional • Works as expected • Expectations are good • Expectations are documented Usability • Secure • Fast • Convenient • Pretty • Consistent • Predictable Strategic • Architecture • Code quality • Easy to integrate • Flexible
  • 53. Copyright © Gaspar NagyCopyright © Gaspar Nagy Pic: http://gasparnagy.com/2017/02/balancing-scenarios-and-unit-tests-case-study-with-specflow/ Timeout Scenario Srv-UI Functional Usability Strategic Edge case Argument check Timeout Test Happy Path Func1 Func2
  • 54. Copyright © Gaspar NagyCopyright © Gaspar Nagy Functional Usability Strategic Forrás: http://gasparnagy.com/2017/02/balancing-scenarios-and-unit-tests-case-study-with-specflow/ Happy path Srv-UI Edge case Argument check Ext call timeout Func1 Func2
  • 55. Copyright © Gaspar NagyCopyright © Gaspar Nagy Srv-UI Functional Usability Strategic Edge case Argument check Ext call timeout Forrás: http://gasparnagy.com/2017/02/balancing-scenarios-and-unit-tests-case-study-with-specflow/ Happy Path Func1 Func2
  • 56. Copyright © Gaspar NagyCopyright © Gaspar Nagy Shall we keep regression tests? • It depends… • If the bug highlighted an important business case – keep it! • If it described a special situation – delete it! • And cover the root cause with technical tests • Maintaining regression scenarios is costly!
  • 57. Copyright © Gaspar NagyCopyright © Gaspar Nagy Working on a legacy app does not mean that you cannot apply BDD process. The scenarios can guide you to discover more and more from the application! As you learn more, the scaffolding can be removed…
  • 58. Copyright © Gaspar NagyCopyright © Gaspar Nagy Happy maintenance!
  • 59. Gáspár Nagy coach • trainer • bdd addict • creator of specflow @gasparnagy • [email protected] Thank you! http://bddbooks.com