BDD for APIs


Published on

How BDD with tools like Cucumber can create a stronger team, a better quality product, and ultimately a more useable API. Given at the #apistrat SF conference 10/24/2013

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Team agreement part is the most significant cultural change for most organizations
  • If code is modularized, it’s possible to integrate behind SoapUI as another test front-end
  • Imperative is more comfortable for developers, and more reuseable for building tests
  • Declarative is more business friendly, but more often than not means writing new code for each feature
  • We need to put ourselves in the shoes of the API consumer in order to better understand any bad behavior we’re exhibiting
  • ----- Meeting Notes (10/22/13 19:05) -----3 advances to show arrows
  • BDD for APIs

    1. 1. BDD for APIs Jason Harmon
    2. 2. Jason Harmon  Blogger @apiux  API Architect @uShip  Likes Python  Works in everything else  ~20 years of tech experience  Background in many integrations
    3. 3. What is BDD?  “Behavior Driven Development”  English readable description of how the product behaves  Defined by team up-front: 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)
    4. 4. What BDD is NOT  A testing framework  Really just an English-readable UI for your own testing implementation  A drop-in solution  You have to write the code  A UI-testing solution, like Selenium  You can actually use Selenium as a driver for Uis, but we‟re talking APIs!
    5. 5. * Agile Testing: A Practical Guide for Testers and Agile Teams (AddisonWesley, 2009)
    6. 6. Supporting the Team Q2 Automated & Manual Tests Business Facing Functional Tests Examples Story Tests Prototypes Simulations
    7. 7. Polyglot friendly Cucumber Ruby-based, the granddaddy of BDD
    8. 8. Polyglot friendly Cucumber-JVM Java implementation, plays nice with Junit and all JVM languages Groovy is quite nice here
    9. 9. Polyglot friendly Specflow .NET, Visual Studio integrated
    10. 10. Polyglot friendly Lettuce Python-based, very similar to Cucumber
    11. 11. Polyglot friendly Behat
    12. 12. Gherkin One Description to Rule Them All Business Readable DSL Not code
    13. 13. Gherkin Example Imperative Style
    14. 14. Gherkin Example Declarative Style
    15. 15. Behavior Driven  User experience trumps all; APIs are no exception  Treat API consumers like first class citizens  Describe how your API behaves from a consumer perspective
    16. 16. Step Definitions
    17. 17. Scenarios “…until it‟s green like a cuke”
    18. 18. Scenario outlines
    19. 19. Errors Red means stop
    20. 20. Tags Very useful for grouping features/scenarios Also useful for ignoring
    21. 21. Agreement Decide during planning how you will test for Acceptance Criteria …AS A TEAM…
    22. 22. Pushback  QA might be uncomfortable with code  Have dev help with a framework, QA can stick to feature files and simple step definition code  Dev might not be happy writing tests  Once they realize QA+PO signs off easy and fast, they‟ll be convinced  Product might just be afraid they have to code or learn something “Techy”  Once they realize it‟s all about business lingo, i.e. „Domain Language‟, they‟re fine
    23. 23. Productivity  Stakeholders know what they‟re getting  Devs know how to build it, less rework  Testers know how to test it, more time to explore  Product knows how to sign off, and quickly  Documentation has a head start
    24. 24. 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
    25. 25. Share!
    26. 26. Share! All BDD tests can be committed to SCM, including branches Provides process which allows collaborative coding on building test framework Code reviews on changes to test framework are able to be automated
    27. 27. Continuous Integration Regression is running all the time Use tags to select the right depth of regression Very fast identification of what‟s broken, in business language
    28. 28. Samples Python/Lettuce Groovy/Cucumber-JVM .NET/SpecFlow Pull requests accepted!
    29. 29. Reading material Posts on BDD with APIs
    30. 30. Thanks Jason Harmon @jasonh_n_austin