SlideShare ist ein Scribd-Unternehmen logo
1 von 42
BDD for APIs
Jason Harmon
Jason Harmon
• Blogger on apiux.com
• API Architect @uShip
• Likes Python
• Works in everything else
• Funny mustache
• Loves weiner dogs
Agile
• INDIVIDUALS AND INTERACTIONS
over processes and tools
–Inside our organization and with our
users
Agile
• WORKING SOFTWARE over
comprehensive documentation
–Not only in our product but our
testing & regression
Agile
• RESPONDING TO CHANGE over
following a plan
– APIs will change for your
business, better have tests
Agile
• CUSTOMER COLLABORATION
over contract negotiation
– Get good at sharing ideas
What is BDD?
• “Behavior Driven Development”
• English readable description of how our
product behaves
• Agreed upon by the team: not Dev, QA or
product owned
• Used to verify the acceptance criteria for
features in a product
• Conceptually like TDD (test-first), but for
functional testing (not code architecture)
* Agile Testing: A Practical Guide for Testers and Agile Teams (Addison-Wesley, 2009)
http://lisacrispin.com/2011/11/08/using-the-agile-testing-quadrants/
Q2 Automated & Manual Tests
Functional Tests
Examples
Story Tests
Prototypes
Simulations
SupportingtheTeam
Business Facing
Polyglot friendly
• Cucumber
– Ruby-based, the granddaddy of BDD
• Cucumber-JVM
– Java implementation, plays nice with Junit and all JVM
languages (Groovy is quite nice here)
• Specflow
– .NET, Visual Studio integrated
• Lettuce
– Python-based, very similar to Cucumber
• Behat
– PHP-based
Gherkin
One Description to Rule Them All
• https://github.com/cucumber/gherkin
• Business Readable
• DSL
• Not code
Gherkin Example
Imperative Style
Scenario: Get nearby place name
Given I use the geonames host
When I access the resource url "/findNearbyPlaceNameJSON"
And I provide parameter "username" as "jharmon"
And I provide parameter "lat" as "30.4754724"
And I provide parameter "lng" as "-98.1564068"
And I retrieve the JSON results
Then the status code should be 200
And it should have a list "geonames"
And the list should have at least 1 item
Gherkin Example
Declarative Style
Scenario: Get nearby place name
Given I use the geonames host
When I use the “Find Nearby Place by JSON” endpoint
And I identify my “geonames” user credentials
And I provide coordinates 30.4754724, -98.1564068
And I retrieve the JSON results
Then it should have at least 1 valid "geonames" item
Behavior Driven
• User experience trumps all
• API is no exception
• Treat API consumers like first class citizens
• Describe how your API behaves from a
consumer perspective
Step Definitions
Scenarios
“…until it’s green like a cuke”
Scenario outlines
Errors
Red means stop
Tags
Lots of power to selectively run groups of tests
Agreement
• Decide during planning how you will test for
Acceptance Criteria
• …AS A TEAM…
• Gherkin/feature definitions will allow a
ubiquitous language
• Technically, this can get easier as the critical
mass of your API interactions is in your testing
framework, and scenario steps are predictable
Productivity
• Stakeholders know what they’re getting
• Devs know how to build it
• Testers know how to test it
• Product knows how to sign off
• Documentation has a head start
Domain Language
• Focus on how you describe everything
• Find agreement on how to describe behavior
• Recognize when behavior is different than
before
– “Wait, we’ve never deleted before!”
• Homework: Domain Driven Design
Share!
• All BDD tests can be committed to
SCM, including branches
• Provide process which allows collaborative
coding on building test framework
• Devs provide expertise on building a scalable
test framework
• Testers utilize existing step definitions to
quickly build out tests
Continuous Integration
• Regression is running all the time
• Use tags to select the right depth of regression
• Very fast identification of what’s broken
Samples
• Python/Lettuce
– https://github.com/jasonh-n-austin/api-bdd-tests
• Groovy/Cucumber-JVM
– https://github.com/jasonh-n-austin/TwitterRestTests
• .NET/SpecFlow
– https://github.com/jasonh-n-austin/TwitterRestTests
Thank You
Jason Harmon
@jasonh_n_austin
http://jhr.mn

Weitere ähnliche Inhalte

Was ist angesagt?

Lessons learned: Choosing your documentation system
Lessons learned: Choosing your documentation systemLessons learned: Choosing your documentation system
Lessons learned: Choosing your documentation system
Pronovix
 
Semi Automatic Code Review
Semi Automatic Code ReviewSemi Automatic Code Review
Semi Automatic Code Review
Richard Huang
 

Was ist angesagt? (20)

Just startcoding
Just startcodingJust startcoding
Just startcoding
 
Beginners overview of automated testing with Rspec
Beginners overview of automated testing with RspecBeginners overview of automated testing with Rspec
Beginners overview of automated testing with Rspec
 
Bdd – with cucumber and gherkin
Bdd – with cucumber and gherkinBdd – with cucumber and gherkin
Bdd – with cucumber and gherkin
 
Hidden Treasure - TestComplete Script Extensions
Hidden Treasure - TestComplete Script ExtensionsHidden Treasure - TestComplete Script Extensions
Hidden Treasure - TestComplete Script Extensions
 
Test Driven Development - a Practitioner’s Perspective
Test Driven Development - a Practitioner’s PerspectiveTest Driven Development - a Practitioner’s Perspective
Test Driven Development - a Practitioner’s Perspective
 
ATAGTR2017 Testing of Connected Cars Based on IOT
ATAGTR2017 Testing of Connected Cars Based on IOTATAGTR2017 Testing of Connected Cars Based on IOT
ATAGTR2017 Testing of Connected Cars Based on IOT
 
Cucumber & gherkin language
Cucumber & gherkin languageCucumber & gherkin language
Cucumber & gherkin language
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
 
Insprint automation, build the culture
Insprint automation, build the cultureInsprint automation, build the culture
Insprint automation, build the culture
 
Introduction to SoapUI day 1
Introduction to SoapUI day 1Introduction to SoapUI day 1
Introduction to SoapUI day 1
 
Automate REST API Testing
Automate REST API TestingAutomate REST API Testing
Automate REST API Testing
 
Jasmine
JasmineJasmine
Jasmine
 
Agile Testing
Agile TestingAgile Testing
Agile Testing
 
Lessons learned: Choosing your documentation system
Lessons learned: Choosing your documentation systemLessons learned: Choosing your documentation system
Lessons learned: Choosing your documentation system
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
Story Testing Approach for Enterprise Applications using Selenium Framework
Story Testing Approach for Enterprise Applications using Selenium FrameworkStory Testing Approach for Enterprise Applications using Selenium Framework
Story Testing Approach for Enterprise Applications using Selenium Framework
 
Semi Automatic Code Review
Semi Automatic Code ReviewSemi Automatic Code Review
Semi Automatic Code Review
 
Level Up Your Salesforce Unit Testing
Level Up Your Salesforce Unit TestingLevel Up Your Salesforce Unit Testing
Level Up Your Salesforce Unit Testing
 
Shift Remote: Mobile - Efficiently Building Native Frameworks for Multiple Pl...
Shift Remote: Mobile - Efficiently Building Native Frameworks for Multiple Pl...Shift Remote: Mobile - Efficiently Building Native Frameworks for Multiple Pl...
Shift Remote: Mobile - Efficiently Building Native Frameworks for Multiple Pl...
 
5 levels of api test automation
5 levels of api test automation5 levels of api test automation
5 levels of api test automation
 

Ähnlich wie BDD for APIs

Ähnlich wie BDD for APIs (20)

Introduction to Testing and TDD
Introduction to Testing and TDDIntroduction to Testing and TDD
Introduction to Testing and TDD
 
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
 
KrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdfKrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdf
 
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
 
Behaviour testing for single-page applications and API’s
Behaviour testing for single-page applications and API’sBehaviour testing for single-page applications and API’s
Behaviour testing for single-page applications and API’s
 
Testing API's: Tools & Tips & Tricks (Oh My!)
Testing API's: Tools & Tips & Tricks (Oh My!)Testing API's: Tools & Tips & Tricks (Oh My!)
Testing API's: Tools & Tips & Tricks (Oh My!)
 
Sustainable agile testing
Sustainable agile testingSustainable agile testing
Sustainable agile testing
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Testing for Logic App Solutions | Integration Monday
Testing for Logic App Solutions | Integration MondayTesting for Logic App Solutions | Integration Monday
Testing for Logic App Solutions | Integration Monday
 
Software Quality without Testing
Software Quality without TestingSoftware Quality without Testing
Software Quality without Testing
 
Agile testing
Agile testingAgile testing
Agile testing
 
The Ultimate API Publisher's Guide
The Ultimate API Publisher's GuideThe Ultimate API Publisher's Guide
The Ultimate API Publisher's Guide
 
Performance testing with JMeter
Performance testing with JMeterPerformance testing with JMeter
Performance testing with JMeter
 
Agile Testing Days 2015 - PIMP MY SCRUM – DOCUMENTATION FUN FOR AGILE TEAMS
Agile Testing Days 2015 - PIMP MY SCRUM – DOCUMENTATION FUN FOR AGILE TEAMSAgile Testing Days 2015 - PIMP MY SCRUM – DOCUMENTATION FUN FOR AGILE TEAMS
Agile Testing Days 2015 - PIMP MY SCRUM – DOCUMENTATION FUN FOR AGILE TEAMS
 
Tools for Software Testing
Tools for Software TestingTools for Software Testing
Tools for Software Testing
 
When & How to Successfully use Test Automation for Mobile Applications
When & How to Successfully use Test Automation for Mobile ApplicationsWhen & How to Successfully use Test Automation for Mobile Applications
When & How to Successfully use Test Automation for Mobile Applications
 
Agile testing
Agile testingAgile testing
Agile testing
 
Enter the mind of an Agile Developer
Enter the mind of an Agile DeveloperEnter the mind of an Agile Developer
Enter the mind of an Agile Developer
 
Testing microservices, contract testing
Testing microservices, contract testingTesting microservices, contract testing
Testing microservices, contract testing
 
DevSecCon Asia 2017 - Abhay Bhargav: Building an Application Vulnerability To...
DevSecCon Asia 2017 - Abhay Bhargav: Building an Application Vulnerability To...DevSecCon Asia 2017 - Abhay Bhargav: Building an Application Vulnerability To...
DevSecCon Asia 2017 - Abhay Bhargav: Building an Application Vulnerability To...
 

Mehr von Jason Harmon

Mehr von Jason Harmon (10)

Essential Ingredients for a Successful API Program
Essential Ingredients for a Successful API ProgramEssential Ingredients for a Successful API Program
Essential Ingredients for a Successful API Program
 
Do's and Don'ts of APIs
Do's and Don'ts of APIsDo's and Don'ts of APIs
Do's and Don'ts of APIs
 
Api Design Anti-Patterns
Api Design Anti-PatternsApi Design Anti-Patterns
Api Design Anti-Patterns
 
Api Design
Api DesignApi Design
Api Design
 
Tools and techniques for APIs
Tools and techniques for APIsTools and techniques for APIs
Tools and techniques for APIs
 
Past, Present, Future of APIS
Past, Present, Future of APISPast, Present, Future of APIS
Past, Present, Future of APIS
 
Scaling API Design
Scaling API DesignScaling API Design
Scaling API Design
 
Scaling API Design - Nordic APIs 2014
Scaling API Design - Nordic APIs 2014Scaling API Design - Nordic APIs 2014
Scaling API Design - Nordic APIs 2014
 
Scaling API Design @restfest
Scaling API Design @restfestScaling API Design @restfest
Scaling API Design @restfest
 
Scaling API Design
Scaling API DesignScaling API Design
Scaling API Design
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

BDD for APIs

  • 2. Jason Harmon • Blogger on apiux.com • API Architect @uShip • Likes Python • Works in everything else • Funny mustache • Loves weiner dogs
  • 3.
  • 4.
  • 5. Agile • INDIVIDUALS AND INTERACTIONS over processes and tools –Inside our organization and with our users
  • 6.
  • 7. Agile • WORKING SOFTWARE over comprehensive documentation –Not only in our product but our testing & regression
  • 8.
  • 9. Agile • RESPONDING TO CHANGE over following a plan – APIs will change for your business, better have tests
  • 10.
  • 11. Agile • CUSTOMER COLLABORATION over contract negotiation – Get good at sharing ideas
  • 12. What is BDD? • “Behavior Driven Development” • English readable description of how our product behaves • Agreed upon by the team: not Dev, QA or product owned • Used to verify the acceptance criteria for features in a product • Conceptually like TDD (test-first), but for functional testing (not code architecture)
  • 13. * Agile Testing: A Practical Guide for Testers and Agile Teams (Addison-Wesley, 2009) http://lisacrispin.com/2011/11/08/using-the-agile-testing-quadrants/
  • 14. Q2 Automated & Manual Tests Functional Tests Examples Story Tests Prototypes Simulations SupportingtheTeam Business Facing
  • 15. Polyglot friendly • Cucumber – Ruby-based, the granddaddy of BDD • Cucumber-JVM – Java implementation, plays nice with Junit and all JVM languages (Groovy is quite nice here) • Specflow – .NET, Visual Studio integrated • Lettuce – Python-based, very similar to Cucumber • Behat – PHP-based
  • 16. Gherkin One Description to Rule Them All • https://github.com/cucumber/gherkin • Business Readable • DSL • Not code
  • 17.
  • 18. Gherkin Example Imperative Style Scenario: Get nearby place name Given I use the geonames host When I access the resource url "/findNearbyPlaceNameJSON" And I provide parameter "username" as "jharmon" And I provide parameter "lat" as "30.4754724" And I provide parameter "lng" as "-98.1564068" And I retrieve the JSON results Then the status code should be 200 And it should have a list "geonames" And the list should have at least 1 item
  • 19. Gherkin Example Declarative Style Scenario: Get nearby place name Given I use the geonames host When I use the “Find Nearby Place by JSON” endpoint And I identify my “geonames” user credentials And I provide coordinates 30.4754724, -98.1564068 And I retrieve the JSON results Then it should have at least 1 valid "geonames" item
  • 20. Behavior Driven • User experience trumps all • API is no exception • Treat API consumers like first class citizens • Describe how your API behaves from a consumer perspective
  • 21.
  • 26. Tags Lots of power to selectively run groups of tests
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32. Agreement • Decide during planning how you will test for Acceptance Criteria • …AS A TEAM… • Gherkin/feature definitions will allow a ubiquitous language • Technically, this can get easier as the critical mass of your API interactions is in your testing framework, and scenario steps are predictable
  • 33. Productivity • Stakeholders know what they’re getting • Devs know how to build it • Testers know how to test it • Product knows how to sign off • Documentation has a head start
  • 34.
  • 35.
  • 36. Domain Language • Focus on how you describe everything • Find agreement on how to describe behavior • Recognize when behavior is different than before – “Wait, we’ve never deleted before!” • Homework: Domain Driven Design
  • 37.
  • 38. Share! • All BDD tests can be committed to SCM, including branches • Provide process which allows collaborative coding on building test framework • Devs provide expertise on building a scalable test framework • Testers utilize existing step definitions to quickly build out tests
  • 39. Continuous Integration • Regression is running all the time • Use tags to select the right depth of regression • Very fast identification of what’s broken
  • 40.
  • 41. Samples • Python/Lettuce – https://github.com/jasonh-n-austin/api-bdd-tests • Groovy/Cucumber-JVM – https://github.com/jasonh-n-austin/TwitterRestTests • .NET/SpecFlow – https://github.com/jasonh-n-austin/TwitterRestTests