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 full-size slide

  2. ENFP PERSONALITY (“THE CAMPAIGNER”)

    View full-size slide

  3. 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 full-size slide

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

    View full-size slide

  5. 150 km
    50 km/h 50 km/h
    75 km/h

    View full-size slide

  6. … 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 full-size slide

  7. 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 full-size slide

  8. 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 full-size slide

  9. "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 full-size slide

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

    View full-size slide

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

    View full-size slide

  12. 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 full-size slide

  13. Illustration by Paul Rayner (Thanks!)

    View full-size slide

  14. 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 full-size slide

  15. 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 full-size slide

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

    View full-size slide

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

    View full-size slide

  18. @Acceptance Testing for Continuous Delivery - Dave Farley

    View full-size slide

  19. @Acceptance Testing for Continuous Delivery - Dave Farley

    View full-size slide

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

    View full-size slide

  21. 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 full-size slide

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

    View full-size slide

  23. ● Commuter
    ● Trains

    View full-size slide

  24. http://eventstorming.com/

    View full-size slide

  25. Choose
    Origin
    Choose
    Destination
    Origin
    Selected
    Destination
    Selected

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  28. Empathy
    Story

    View full-size slide

  29. Questions?
    #CATTAX

    View full-size slide