Speed, Agility, Resilience
Trusted Experts in Microservices, Cloud Native & Chaos Engineering
  • Home
  • EBooks
  • Contact Us
  • Consultancy
    • One-to-One Online Consultancy
    • Onsite Consultancy
  • Training
    • One-to-One Online Training
    • Building Reliable Systems
    • Building Antifragile Systems with Microservices Course
    • Fast Track to Cloud Native Java
    • Fast Track to Applying DDD for Effective Microservices
    • Fast Track to Running Production Microservices
    • Fast Track to Chaos Engineering
    • Autumn of Cloud Native
  • Speaking
    • Schedule
    • Slides and Videos
    • Brown Bag Events
  • Blog
  • FAQ
  • Client Feedback
  • Gallery
  • (Print) Books
  • Essais

Implementing Journeys, not Interactions, with Serenity 1.1.5 (full article)

8/18/2015

0 Comments

 
When I describe my morning it invariably sounds boringly like the following:

“This morning I left the house, locking it with my key, and then I took a train, as I have a ticket, to London Waterloo East before taking the Tube, because I have a ticket, to the windy monoliths of Canary Wharf."

Ok, so it’s not the most riveting of stories! But it does effectively explain my experience as I journey in towards London and some of our clients.

If I was to describe the above interaction in terms of web acceptance testing, it would look like the following:

“Leave and Lock House; Interact to Catch Train; Interact to Catch Tube; Assert that I’m in Canary Wharf”.

That’s pretty ugly, and look at the information that has been lost in translation! Specifically I’ve lost the person involved, me, the abilities that I have, and the tasks I accomplish.

“This morning Russ (the Actor) left the house, locking it (Task) with my key (Ability), and then I took a train (Task), as I have a ticket (another Ability), to London Waterloo East before taking the Tube (Task), because I have a ticket (another Ability), to the windy monoliths of Canary Wharf (Consequence!)."

I want to describe a journey in my tests, a flow that the participants are involved in, not just a set of interactions.

And now as of Serenity BDD 1.1.5 I get this capability.


The Journey Model

Serenity BDD has now incorporated an early version of a new conceptual model, the Journey Model for describing the behaviour, or more accurately the journey, that needs to be supported by the software system under test.

I originally encountered the Journey Model in this post by Andy Palmer. 

For those that have grabbed the Serenity Core code, implementation is in the serenity-journey package.

In the past when you are creating tests that assert the behaviour of a given web-based system you would capture the important interactions of the test through Steps. A typical test would look like the following from the Serenity BDD samples:

  @Steps
  public GoogleSearchSteps steps;

  @Test
   public void searching_for_cats_should_find_the_wikipedia_entry() {
      steps.open_home_page();
      steps.searchFor("cats");
      steps.resultListShouldContain("Cat - Wikipedia, the free encyclopedia");
  }

Throughout the test there is a set of Steps, scoped for the test, that encapsulate  a number of interactions with Page Objects to lead to a point where some useful assertions could be applied.

Knowing the What, Losing the WhoThe challenge with this Page Object interaction model is that a lot of detail is lost.

We know what happens, but not Who does it, or even what they are capable of!

When stakeholders are describing their stories for how the software should work, who is often as important as what.

What is needed is a new model that describes who does what in the form of a larger narrative.

Enter, stage left, the Journey Model.


Who and Their Journey

The Journey Model focusses on describing the flow using the driving concept of the people, and or systems, involved.

Picture
Breaking the model down, here are the important concepts:

  • Actors - The People or Systems that drive the journey’s flow.
  • Abilities - Things that enable and actors to actually do something.
  • Tasks - Activities that an Actor will Perform.
  • Consequence - An expectation set up as a Question and an answering Matcher.

Those are the key concepts, time to look at some code.


A Journey in Serenity BDD Code

The sample code below comes from the current sample that is part of the core Serenity BDD source code.

Starting aptly from the outside-in, let’s first take a look at the Journey model being used in the actual Serenity test:

    @Test
    public void danaCanClickOnButtons() {

        Actor dana = new Actor("Dana");

        dana.can(BrowseTheWeb.with(driver));

        givenThat(dana).has(openedTheApplication);

        when(dana).attemptsTo(viewHerProfile);
        and(dana).attemptsTo(updateHer.name().to("Dana"));

        then(dana).should(seeThat(herProfile.name(), equalTo("Dana")));
    }

The first thing to do in a Journey model test is to create the Who, the Actor. In our case the actor is Dana and she is going to be able to do some things.

The next line introduces an Ability to Dana, she can BrowseTheWeb using a particular Serenity managed WebDriver.

Next Dana is asked to do some things, some Tasks. Tasks are captured as special Serenity Steps, special in that they contain only one step in each case.

Finally a number of Consequences, combinations of Questions and Hamcrest Matchers in this case, applied to assert that Dana should be able to do something after those tasks.


Watch this Space

This implementation of the Journey model is incredibly useful but there is plenty more to come.

Keep watching this space for more examples of the Journey model as additional features are added.

One area I’m especially interested in is how the Journey model can be used to more effectively communicate and build confidence in a collection of microservices...

0 Comments



Leave a Reply.

    Musings on software development

    Archives

    September 2017
    June 2017
    November 2016
    September 2016
    May 2016
    February 2016
    September 2015
    August 2015
    June 2015
    March 2015
    January 2015
    December 2014
    November 2014
    October 2014
    June 2014
    May 2014
    April 2014
    March 2014
    February 2014
    December 2013
    August 2013

    Categories

    All
    Announcements
    Antifragile
    Books
    Innovation
    Life Preserver
    Microservices
    Philosophy
    Psychology
    Reviews
    Software

    RSS Feed

Products

EBooks
​(Print) Books
Consultancy
Training
​
Speaking

Company

Essais
FAQ
Client feedback
Gallery

Support

Contact
Picture
© COPYRIGHT 2018. ALL RIGHTS RESERVED.


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.