Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Domain Language throughout Tests, combining DDD and BDD

Domain Language throughout Tests, combining DDD and BDD

While software engineers are beginning to use the language of the domain (business language) more in their application code, in most tests we still see a lot of technical language. Especially when creating acceptance test for a GUI, we mostly go from gherkin to Selenium straight away! With the ever-growing culture of creating living documentation in the form of gherkin, it is evenly important to use the domain language in our test code too.

In this talk, I will explain how to combine Domain Driven Design (DDD) and Behaviour Driven Development (BDD). I will use Feature Mapping with Event Storming and Example Mapping so we can create a ubiquitous domain language that we can use in our application and test code. Using property-based testing and the Screenplay pattern, I will show several examples on how to use the domain language in test code. As a result, we have tests that are both useful for communication and serve as living documentation based on our domain language.

Kenny Baas-Schwegler

February 02, 2018
Tweet

More Decks by Kenny Baas-Schwegler

Other Decks in Technology

Transcript

  1. Domain Language throughout Tests,
    combining DDD and BDD
    @kenny_baas
    Baasie.com

    View Slide

  2. View Slide

  3. ENFP PERSONALITY (“THE CAMPAIGNER”)

    View Slide

  4. Curious
    Imaginative and open-minded, seeing all things as part of a big, mysterious
    puzzle called life.
    Overthink Things
    They look for underlying motives in even
    the simplest things. It’s not uncommon for ENFPs to lose a bit of
    sleep asking themselves why someone did what they did,
    what it might mean, and what to do about it.
    ©https://www.16personalities.com/

    View Slide

  5. View Slide

  6. ©https://www.16personalities.com/

    View Slide

  7. View Slide

  8. 150 km
    50 km/h 50 km/h
    75 km/h

    View Slide

  9. … he solved it in an instant, and thereby disappointed the
    questioner: “Oh, you must have heard the trick before!” “What
    trick?” asked von Neumann, “All I did was sum the geometric
    series.”
    http://engineering.pivotal.io/post/abstraction-or-the-gift-of-our-weak-brains/

    View Slide

  10. 150 km
    50 km/h 50 km/h
    75 km/h
    1. you know the total time the fly is traveling (based on the trains’ relative speeds); (1:30 hour)
    2. and you’re given the fly’s speed.
    A simple velocity calculation later, and you have the answer. (75x1.5=112.5 km)

    View Slide

  11. electron behavior is actually so complicated,
    involving complex interactions between
    quantum probabilities, electromagnetic
    interactions, and macroscopic electric fields,
    that human brains are piteously underpowered
    to calculate what’s going on in an individual
    atom.
    http://engineering.pivotal.io/post/abstraction-or-the-gift-of-our-weak-brains/

    View Slide

  12. "Let us change our traditional attitude to the
    construction of programs: Instead of imagining
    that our main task is to instruct a computer what
    to do, let us concentrate rather on explaining
    to human beings what we want a computer
    to do"
    - Donald Knuth - Literate Programming
    “Programs must be written for people to read,
    and only incidentally for machines to execute.”
    - Hal Abelson
    http://engineering.pivotal.io/post/abstraction-or-the-gift-of-our-weak-brains/

    View Slide

  13. View Slide

  14. View Slide

  15. ©https://www.16personalities.com/

    View Slide

  16. View Slide

  17. View Slide

  18. ©https://www.16personalities.com/

    View Slide

  19. Feature: search Wikipedia
    Background:
    Given Open http://en.wikipedia.org
    And Do login
    Scenario: direct search article
    Given Enter search term 'Cucumber'
    When Do search
    Then Single result is shown for 'Cucumber'
    https://cucumber.io/blog/2014/03/03/the-worlds-most-misunderstood-collaboration-tool
    The world's most misunderstood collaboration tool

    View Slide

  20. Illustration by Paul Rayner (Thanks!)

    View Slide

  21. View Slide

  22. All your dreams are made
    When you're chained to the mirror and the razor blade
    Today's the day that all the world will see
    Another sunny afternoon
    Walking to the sound of my favorite tune
    Tomorrow never knows what it doesn't know
    too soon
    Need a little time to wake up
    Need a little time to wake up wake up
    Need a little time to wake up
    Need a little time to rest your mind
    You know you should so I guess you might
    as well
    What's the story morning glory?
    Well
    You need a little time to wake up wake up
    Well
    What's the story morning glory?

    View Slide

  23. All your dreams are made
    When you're chained to the mirror and the razor blade
    Today's the day that all the world will see
    Another sunny afternoon
    Walking to the sound of my favorite tune
    Tomorrow never knows what it doesn't know
    too soon
    Need a little time to wake up
    Need a little time to wake up wake up
    Need a little time to wake up
    Need a little time to rest your mind
    You know you should so I guess you might
    as well
    What's the story morning glory?
    Well
    You need a little time to wake up wake up
    Well
    What's the story morning glory?

    View Slide

  24. View Slide

  25. View Slide

  26. "Software Development is about
    learning, working code is a side
    effect"
    Alberto Brandolini @ziobrando

    View Slide

  27. View Slide

  28. View Slide

  29. View Slide

  30. View Slide

  31. View Slide

  32. ©https://www.16personalities.com/

    View Slide

  33. View Slide

  34. @Acceptance Testing for Continuous Delivery - Dave Farley

    View Slide

  35. @Acceptance Testing for Continuous Delivery - Dave Farley

    View Slide

  36. View Slide

  37. https://dddeurope.com/2017/speakers/romeu-moura/

    View Slide

  38. View Slide

  39. Navigation by public transport
    In order to know the fastest route between two places,
    As a commuter
    I want get to my destination as quickly as possible

    View Slide

  40. View Slide

  41. View Slide

  42. View Slide

  43. https://johnfergusonsmart.com/feature-mapping-a-simpler-path-from-stories-to-executable-acceptance-criteria/

    View Slide

  44. ● Commuter
    ● Trains

    View Slide

  45. http://eventstorming.com/

    View Slide

  46. View Slide

  47. Choose
    Origin
    Choose
    Destination
    Origin
    Selected
    Destination
    Selected

    View Slide

  48. https://cucumber.io/blog/2015/12/08/example-mapping-introduction

    View Slide

  49. View Slide

  50. View Slide

  51. View Slide

  52. http://serenity-js.org/design/screenplay-pattern.html

    View Slide

  53. View Slide

  54. View Slide

  55. #
    WRAPUP

    View Slide

  56. Empathy
    Story

    View Slide

  57. Questions?
    #CATTAX

    View Slide