Discussion:
[Cucumber] [Gherkin] [JVM] Stateful Scenarios/Examples in Cucumber
(too old to reply)
Mark Levison
2015-01-14 19:35:56 UTC
Permalink
Thanks for the Cucumber JVM and the book you've recently launched with the
Pragmatics, its given me the impetus after all these years to try Cucumber.
After mucking around with basic sorts of examples in the book I've
graduated to something a little more challenging.

For a while now I've been developing a game I play with clients and at
conferences - The High Performance Teams Game - outlined here:
http://agilepainrelief.com/notesfromatooluser/2015/01/welcome-to-the-high-performance-teams-game.html

The point of the game is to help teams reflect on the costs and effects of
various agile engineering (CI, Unit Testing, ...) and social practices
(team rooms, working agreements). By playing the game they discover if they
focus only delivering stories their capacity degrades rapidly, however if
the take on engineering and/or social practices their capacity can either
stabilize or improve. As I was first designing the game I was struck that
this would be perfect vehicle to help me learn Cucumber.

The game takes place over a series of 5-6 (or more) rounds. In each round
team members must decide if they will give into the inevitable pressure to
deliver more stories or set aside some of their efforts to improve. In
addition most actions don't have an affect in the round taken but 1-2
rounds later. Finally some effects are merely preventative i.e. ScrumMaster
protects teams from outside interference doesn't improve productivity
merely stops it being degraded later.

The challenge I'm having is expressing tests that capture the idea that
state will persist over a series of rounds. *I do appreciate why on
principle Cucumber isn't intended to be stateful.*

What I would like to do is write tables that look something like this:

| Round | Action(s) | Capacity |
| 1 | CI, CreateTeamSpace | 10 |
| 2 | UnitTesting, SMProtectsTeam | 8 |
| 3 | Nothing | 12 |
| 4 | Nothing | 12 |
| 5 | Nothing | 10 |
| 6 | Nothing | 9 |

(the numbers here are just rough examples I have figured out this
particular scenario in detail)

I understand how to write simple example tables but in these cases the
state doesn't persist between rounds.

Here's one I've written:
Feature: Teams Degrade more slowly with only a single engineering practice

Scenario Outline: slower degradation
Given My Teams IntialCapacity is 10
When CI Improved
Then After <Round> rounds the teams capacity to <Capacity>
Examples: CI practice implemented in the first round
| Round | Capacity |
| 1 | 10 |
| 2 | 8 |
| 3 | 6 |
| 4 | 4 |
| 5 | 2 |
| 6 | 0 |

---
If I tried to do this the way I'm going in the second example I'm going to
spend a lot of time creating very complex when statements that say: CI,
CreateTeamSpace, Round 1; UnitTesting, SMProtectsTeam, Round 2; ....

While this would work on a technical level I seem to be missing the
readability I would expect in Cucumber.

Help me see what I've missed.

BTW If a little less coherent than usual I'm just off a red eye.

Thanks
Mark
--
[image: headshot-square-300x300]
<http://www.flickr.com/photos/***@N00/9674877046/>*Mark Levison* | 1
(877) 248-8277 | Twitter <https://twitter.com/mlevison> | LinkedIn
<http://ca.linkedin.com/in/marklevison> | Facebook
<https://www.facebook.com/agilepainrelief>
Certified ScrumMaster Training: Vancouver
<http://agilepainrelief.com/courses/vancouver> | Edmonton
<http://agilepainrelief.com/courses/edmonton> | Ottawa
<http://agilepainrelief.com/courses/ottawa> | Montreal
<http://agilepainrelief.com/courses/montreal> | Toronto
<http://agilepainrelief.com/courses/toronto>
Certified Product Owner & Private Training also available ~ Our Training
Schedule <http://agilepainrelief.com/courses/certified-scrum-agile-training>
Agile Pain Relief Consulting <http://agilepainrelief.com/> | Notes from a
Tool User <http://agilepainrelief.com/notesfromatooluser>
Proud Sponsor of Agile Tour Gatineau Ottawa <http://goagiletour.ca/> and Agile
Coach Camp Canada <http://agilecoachcampcanada.wordpress.com/>
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Andrew Premdas
2015-01-15 09:14:49 UTC
Permalink
Seems to me that by using tables you are writing scenarios that are pretty
unreadable. Instead of trying to program using gherkin, consider expressing
the features in a better way so you don't need the tables.

As for the technical bit, state should not persist between different test
invocations. Your example creates a NEW test for each row in the table,
which is why you cannot carry forward the state.

Your problem seem to be basically similar to a wizard, that is you have a
series of actions which build on each other. You can write elegant features
for this by using creative naming. First of all you need a name for each
action and a name for each state that you have arrived at after each
action. Then you use these in a series of scenarios. An example might help

Checkout: Give addr

Given i"m buying something
When I provide my address
Then I should be asked for payment

Given I'm paying for something
When I pay by card
...

Both of these features start out with a step that takes you to a particular
state. Then you do something and you get to a later state. Its relatively
easy to implement the steps for this in an elegant manner by extracting the
how into methods which youu re-use e.g.

def buy_product(prod)
visit product_page(page)
add_to_basket
end


def buying_something
buy_product(something)
end

def provide_address
fill_in ...
...
end

def paying_for_something
buying_something
fill_in_address
end
etc,. etc.


Note: How there is no programmin in the features, and how
paying_for_something gets all the state from buying_something with no
effort.

HTH

Andrew
Post by Mark Levison
Thanks for the Cucumber JVM and the book you've recently launched with the
Pragmatics, its given me the impetus after all these years to try Cucumber.
After mucking around with basic sorts of examples in the book I've
graduated to something a little more challenging.
For a while now I've been developing a game I play with clients and at
http://agilepainrelief.com/notesfromatooluser/2015/01/welcome-to-the-high-performance-teams-game.html
The point of the game is to help teams reflect on the costs and effects of
various agile engineering (CI, Unit Testing, ...) and social practices
(team rooms, working agreements). By playing the game they discover if they
focus only delivering stories their capacity degrades rapidly, however if
the take on engineering and/or social practices their capacity can either
stabilize or improve. As I was first designing the game I was struck that
this would be perfect vehicle to help me learn Cucumber.
The game takes place over a series of 5-6 (or more) rounds. In each round
team members must decide if they will give into the inevitable pressure to
deliver more stories or set aside some of their efforts to improve. In
addition most actions don't have an affect in the round taken but 1-2
rounds later. Finally some effects are merely preventative i.e. ScrumMaster
protects teams from outside interference doesn't improve productivity
merely stops it being degraded later.
The challenge I'm having is expressing tests that capture the idea that
state will persist over a series of rounds. *I do appreciate why on
principle Cucumber isn't intended to be stateful.*
| Round | Action(s) | Capacity |
| 1 | CI, CreateTeamSpace | 10 |
| 2 | UnitTesting, SMProtectsTeam | 8 |
| 3 | Nothing | 12 |
| 4 | Nothing | 12 |
| 5 | Nothing | 10 |
| 6 | Nothing | 9 |
(the numbers here are just rough examples I have figured out this
particular scenario in detail)
I understand how to write simple example tables but in these cases the
state doesn't persist between rounds.
Feature: Teams Degrade more slowly with only a single engineering practice
Scenario Outline: slower degradation
Given My Teams IntialCapacity is 10
When CI Improved
Then After <Round> rounds the teams capacity to <Capacity>
Examples: CI practice implemented in the first round
| Round | Capacity |
| 1 | 10 |
| 2 | 8 |
| 3 | 6 |
| 4 | 4 |
| 5 | 2 |
| 6 | 0 |
---
If I tried to do this the way I'm going in the second example I'm going
to spend a lot of time creating very complex when statements that say: CI,
CreateTeamSpace, Round 1; UnitTesting, SMProtectsTeam, Round 2; ....
While this would work on a technical level I seem to be missing the
readability I would expect in Cucumber.
Help me see what I've missed.
BTW If a little less coherent than usual I'm just off a red eye.
Thanks
Mark
--
[image: headshot-square-300x300]
(877) 248-8277 | Twitter <https://twitter.com/mlevison> | LinkedIn
<http://ca.linkedin.com/in/marklevison> | Facebook
<https://www.facebook.com/agilepainrelief>
Certified ScrumMaster Training: Vancouver
<http://agilepainrelief.com/courses/vancouver> | Edmonton
<http://agilepainrelief.com/courses/edmonton> | Ottawa
<http://agilepainrelief.com/courses/ottawa> | Montreal
<http://agilepainrelief.com/courses/montreal> | Toronto
<http://agilepainrelief.com/courses/toronto>
Certified Product Owner & Private Training also available ~ Our Training
Schedule
<http://agilepainrelief.com/courses/certified-scrum-agile-training>
Agile Pain Relief Consulting <http://agilepainrelief.com/> | Notes from a
Tool User <http://agilepainrelief.com/notesfromatooluser>
Proud Sponsor of Agile Tour Gatineau Ottawa <http://goagiletour.ca/> and Agile
Coach Camp Canada <http://agilecoachcampcanada.wordpress.com/>
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
------------------------
Andrew Premdas
blog.andrew.premdas.org
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Seb Rose
2015-01-15 11:01:00 UTC
Permalink
Post by Mark Levison
Thanks for the Cucumber JVM and the book you've recently launched with
the Pragmatics, its given me the impetus after all these years to try
Cucumber. After mucking around with basic sorts of examples in the
book I've graduated to something a little more challenging.
For a while now I've been developing a game I play with clients and at
http://agilepainrelief.com/notesfromatooluser/2015/01/welcome-to-the-high-performance-teams-game.html
The point of the game is to help teams reflect on the costs and
effects of various agile engineering (CI, Unit Testing, ...) and
social practices (team rooms, working agreements). By playing the game
they discover if they focus only delivering stories their capacity
degrades rapidly, however if the take on engineering and/or social
practices their capacity can either stabilize or improve. As I was
first designing the game I was struck that this would be perfect
vehicle to help me learn Cucumber.
The game takes place over a series of 5-6 (or more) rounds. In each
round team members must decide if they will give into the inevitable
pressure to deliver more stories or set aside some of their efforts to
improve. In addition most actions don't have an affect in the round
taken but 1-2 rounds later. Finally some effects are merely
preventative i.e. ScrumMaster protects teams from outside interference
doesn't improve productivity merely stops it being degraded later.
The challenge I'm having is expressing tests that capture the idea
that state will persist over a series of rounds. *I do appreciate why
on principle Cucumber isn't intended to be stateful.*
| Round | Action(s) | Capacity | 1 | CI, CreateTeamSpace | 10 | 2 |
| UnitTesting, SMProtectsTeam | 8 | 3 | Nothing | 12 | 4 | Nothing |
| 12 | 5 | Nothing | 10 | 6 | Nothing | 9 |
I think this scenario is suffering from "Incidental Details" (see the
Chapter - Keeping Your Cucumbers Sweet). It's difficult to see exactly
what's being specified or to spot if the expectations are wrong. I'd
try more targeted scenarios that describe the actual rules of the
system, such as:

Scenario: Capacity degrades each round if no action is taken When the
team only focuses on delivering stories Then capacity decreases by 2
each round # The support code is responsible for looping & checking

Scenario: CI gives delayed increase to capacity When the team implements
CI # Does it matter what round this happens in? Maybe we need to set
context with a Given step Then capacity improves by 2 in the next round

The benefits of this approach are:
- these rules document your game
- the customer can easily review them and agree (or disagree) with them
- the complexity is pushed into the glue/support code
- each scenario is isolated and independent
Post by Mark Levison
(the numbers here are just rough examples I have figured out this
particular scenario in detail)
I understand how to write simple example tables but in these cases the
state doesn't persist between rounds.
Here's one I've written: Feature: Teams Degrade more slowly with only
a single engineering practice
Scenario Outline: slower degradation Given My Teams IntialCapacity
is 10 When CI Improved Then After <Round> rounds the teams capacity
to <Capacity> Examples: CI practice implemented in the first round
| Round | Capacity | | 1 | 10| | 2 | 8| | 3 | 6| | 4 | 4 | | 5 | 2
| | 6 | 0 |
--- If I tried to do this the way I'm going in the second example I'm
going to spend a lot of time creating very complex when statements
that say: CI, CreateTeamSpace, Round 1; UnitTesting, SMProtectsTeam,
Round 2; ....
While this would work on a technical level I seem to be missing the
readability I would expect in Cucumber.
Help me see what I've missed.
BTW If a little less coherent than usual I'm just off a red eye.
Thanks Mark
--
headshot-square-300x300 *Mark Levison* | 1 (877) 248-8277 | Twitter[1]
Vancouver[4] | Edmonton[5] | Ottawa[6] | Montreal[7] | Toronto[8]
Certified Product Owner & Private Training also available ~ Our
Training Schedule[9] Agile Pain Relief Consulting[10] | Notes from a
Tool User[11] Proud Sponsor of Agile Tour Gatineau Ottawa[12] and
Agile Coach Camp Canada[13]
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google
Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
The Cucumber for Java Book - Seb Rose, Matt Wynne & Aslak Hellesøy Now
available from the Pragmatic Press -
https://pragprog.com/book/srjcuc/the-cucumber-for-java-book



Links:

1. https://twitter.com/mlevison
2. http://ca.linkedin.com/in/marklevison
3. https://www.facebook.com/agilepainrelief
4. http://agilepainrelief.com/courses/vancouver
5. http://agilepainrelief.com/courses/edmonton
6. http://agilepainrelief.com/courses/ottawa
7. http://agilepainrelief.com/courses/montreal
8. http://agilepainrelief.com/courses/toronto
9. http://agilepainrelief.com/courses/certified-scrum-agile-training
10. http://agilepainrelief.com/
11. http://agilepainrelief.com/notesfromatooluser
12. http://goagiletour.ca/
13. http://agilecoachcampcanada.wordpress.com/
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Richard Lawrence
2015-01-15 20:26:18 UTC
Permalink
Hi Mark,

I agree with Seb's advice, but I'd add...

If you really want to use the tables in your scenarios because the rounds
seem like an essential detail for your domain, you would use them as step
arguments in a concrete scenario rather than examples for a scenario
outline. For example:

Scenario: CI in round 1 - does such and such
Given my team's initial capacity is 10
When CI improves in round 1
Then the team's capacity should change as follows:
| Round | Capacity |
| 1 | 10 |
| 2 | 8 |
| 3 | 6 |
| 4 | 4 |
| 5 | 2 |
| 6 | 0 |

The "does such and such" in the scenario title is a placeholder for
explaining why this particular sequence of capacities has anything to do
with CI—it's not obvious from the scenario itself.

I don't love this scenario, but scenario language is personal and
context-specific, and you may like exposing the detail of multiple rounds
in your scenarios because you know more about the domain than I do.

Richard

P.S. - Sorry for top posting, Aslak. I couldn't figure out how to respond
inline to both Mark's original post and Seb's reply with the original
snipped.
Post by Mark Levison
Thanks for the Cucumber JVM and the book you've recently launched with the
Pragmatics, its given me the impetus after all these years to try Cucumber.
After mucking around with basic sorts of examples in the book I've
graduated to something a little more challenging.
For a while now I've been developing a game I play with clients and at
http://agilepainrelief.com/notesfromatooluser/2015/01/welcome-to-the-high-performance-teams-game.html
The point of the game is to help teams reflect on the costs and effects of
various agile engineering (CI, Unit Testing, ...) and social practices
(team rooms, working agreements). By playing the game they discover if they
focus only delivering stories their capacity degrades rapidly, however if
the take on engineering and/or social practices their capacity can either
stabilize or improve. As I was first designing the game I was struck that
this would be perfect vehicle to help me learn Cucumber.
The game takes place over a series of 5-6 (or more) rounds. In each round
team members must decide if they will give into the inevitable pressure to
deliver more stories or set aside some of their efforts to improve. In
addition most actions don't have an affect in the round taken but 1-2
rounds later. Finally some effects are merely preventative i.e. ScrumMaster
protects teams from outside interference doesn't improve productivity
merely stops it being degraded later.
The challenge I'm having is expressing tests that capture the idea that
state will persist over a series of rounds. *I do appreciate why on
principle Cucumber isn't intended to be stateful.*
| Round | Action(s) | Capacity |
| 1 | CI, CreateTeamSpace | 10 |
| 2 | UnitTesting, SMProtectsTeam | 8 |
| 3 | Nothing | 12 |
| 4 | Nothing | 12 |
| 5 | Nothing | 10 |
| 6 | Nothing | 9 |
I think this scenario is suffering from "Incidental Details" (see the
Chapter - Keeping Your Cucumbers Sweet). It's difficult to see exactly
what's being specified or to spot if the expectations are wrong. I'd try
more targeted scenarios that describe the actual rules of the system, such
Scenario: Capacity degrades each round if no action is taken
When the team only focuses on delivering stories
Then capacity decreases by 2 each round # The support code is
responsible for looping & checking
Scenario: CI gives delayed increase to capacity
When the team implements CI # Does it matter what round this happens
in? Maybe we need to set context with a Given step
Then capacity improves by 2 in the next round
- these rules document your game
- the customer can easily review them and agree (or disagree) with them
- the complexity is pushed into the glue/support code
- each scenario is isolated and independent
(the numbers here are just rough examples I have figured out this
particular scenario in detail)
I understand how to write simple example tables but in these cases the
state doesn't persist between rounds.
Feature: Teams Degrade more slowly with only a single engineering practice
Scenario Outline: slower degradation
Given My Teams IntialCapacity is 10
When CI Improved
Then After <Round> rounds the teams capacity to <Capacity>
Examples: CI practice implemented in the first round
| Round | Capacity |
| 1 | 10|
| 2 | 8|
| 3 | 6|
| 4 | 4 |
| 5 | 2 |
| 6 | 0 |
---
If I tried to do this the way I'm going in the second example I'm going
to spend a lot of time creating very complex when statements that say: CI,
CreateTeamSpace, Round 1; UnitTesting, SMProtectsTeam, Round 2; ....
While this would work on a technical level I seem to be missing the
readability I would expect in Cucumber.
Help me see what I've missed.
BTW If a little less coherent than usual I'm just off a red eye.
Thanks
Mark
--
[image: headshot-square-300x300]
*Mark Levison* | 1 (877) 248-8277 | Twitter <https://twitter.com/mlevison>
| LinkedIn <http://ca.linkedin.com/in/marklevison> | Facebook
<https://www.facebook.com/agilepainrelief>
Certified ScrumMaster Training: Vancouver
<http://agilepainrelief.com/courses/vancouver> | Edmonton
<http://agilepainrelief.com/courses/edmonton> | Ottawa
<http://agilepainrelief.com/courses/ottawa> | Montreal
<http://agilepainrelief.com/courses/montreal> | Toronto
<http://agilepainrelief.com/courses/toronto>
Certified Product Owner & Private Training also available ~ Our Training
Schedule
<http://agilepainrelief.com/courses/certified-scrum-agile-training>
Agile Pain Relief Consulting <http://agilepainrelief.com/> | Notes from a
Tool User <http://agilepainrelief.com/notesfromatooluser>
Proud Sponsor of Agile Tour Gatineau Ottawa <http://goagiletour.ca/> and Agile
Coach Camp Canada <http://agilecoachcampcanada.wordpress.com/>
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
The Cucumber for Java Book - Seb Rose, Matt Wynne & Aslak HellesÞy
Now available from the Pragmatic Press -
https://pragprog.com/book/srjcuc/the-cucumber-for-java-book
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mark Levison
2015-01-15 20:44:58 UTC
Permalink
Thank you Andrew, Seb and Richard. I've taken a few minutes to review the
advice - Seb's observation helped me see the problem in a different way,
strangely its probably the same question I would have asked if I was
pairing with me :-)

Richard thanks for helping me see that there is an alternative if less
elegant way to express this. Tomorrow I suspect much of my will be spent
working on my business and review A2015 proposals, so I probably won't get
to code again until Monday/Tuesday expect supplementary questions then.

Cheers
Mark
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mark Levison
2015-01-20 16:33:54 UTC
Permalink
Just for fun I'm going to document what I learned in the past 60 minutes of
coffee and code.

*Feature*: Teams Degrade if nothing done

*Scenario*: Capacity degrades each round if no action is taken

*When* the team only focuses on delivering stories

*Then* capacity decreases by 4 each round # The support code is
responsible for looping & checking

Led to complex test code because there are two funny conditions:

- The pain doesn't take effect until the 2nd round - its intended to
simulate the fact that we can get away with a bad habits for a few
weeks/sprints/iterations before our mistakes start to burn us

- Not allowing the team's capacity to go below zero led to special case
code in the tests

... I'm only including the Then statement here:

@Then("^capacity decreases by (\\d+) each round # The support code
is responsible for looping & checking$")
public void capacity_decreases_by_each_round_The_support_code_is_responsible_for_looping_checking(
int capacityReduction) throws Throwable {

// First Round no effect
teams.executeAction(ActionType.NoImprovement);

while (teams.getCapacity() > 0) {
int expectedCapacity = Math.max(0, teams.getCapacity()
- capacityReduction);
teams.executeAction(ActionType.NoImprovement);
Assert.assertThat(teams.getCapacity(),
is(equalTo(expectedCapacity)));
}
}

​So this particular path appears to be an evolutionary dead end.

Cheers
Mark​


[image: headshot-square-300x300]
<http://www.flickr.com/photos/***@N00/9674877046/>*Mark Levison* | 1
(877) 248-8277 | Twitter <https://twitter.com/mlevison> | LinkedIn
<http://ca.linkedin.com/in/marklevison> | Facebook
<https://www.facebook.com/agilepainrelief>
Certified ScrumMaster Training: Vancouver
<http://agilepainrelief.com/courses/vancouver> | Edmonton
<http://agilepainrelief.com/courses/edmonton> | Ottawa
<http://agilepainrelief.com/courses/ottawa> | Montreal
<http://agilepainrelief.com/courses/montreal> | Toronto
<http://agilepainrelief.com/courses/toronto>
Certified Product Owner & Private Training also available ~ Our Training
Schedule <http://agilepainrelief.com/courses/certified-scrum-agile-training>
Agile Pain Relief Consulting <http://agilepainrelief.com/> | Notes from a
Tool User <http://agilepainrelief.com/notesfromatooluser>
Proud Sponsor of Agile Tour Gatineau Ottawa <http://goagiletour.ca/> and Agile
Coach Camp Canada <http://agilecoachcampcanada.wordpress.com/>
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Richard Lawrence
2015-01-20 16:49:27 UTC
Permalink
Post by Mark Levison
Just for fun I'm going to document what I learned in the past 60 minutes
of coffee and code.
*Feature*: Teams Degrade if nothing done
*Scenario*: Capacity degrades each round if no action is taken
*When* the team only focuses on delivering stories
*Then* capacity decreases by 4 each round # The support code is
responsible for looping & checking
- The pain doesn't take effect until the 2nd round - its intended to
simulate the fact that we can get away with a bad habits for a few
weeks/sprints/iterations before our mistakes start to burn us
- Not allowing the team's capacity to go below zero led to special case
code in the tests
@Then("^capacity decreases by (\\d+) each round # The support code is responsible for looping & checking$")
public void capacity_decreases_by_each_round_The_support_code_is_responsible_for_looping_checking(
int capacityReduction) throws Throwable {
// First Round no effect
teams.executeAction(ActionType.NoImprovement);
while (teams.getCapacity() > 0) {
int expectedCapacity = Math.max(0, teams.getCapacity()
- capacityReduction);
teams.executeAction(ActionType.NoImprovement);
Assert.assertThat(teams.getCapacity(),
is(equalTo(expectedCapacity)));
}
}
A quick note on your step definitions: They're not quite doing what the
steps say. Some of what I see in your Then step def probably belongs in the
When step def because it's the code to have "the team only focus[] on
delivering stories." The pattern to use here is take the action in the When
step def, capturing the results into shared state if necessary, and just
check and assert in the Then step def. This makes failures easier to
interpret—i.e., did the system fail to take the action or did the action
not produce the expected results?

So, you'd probably build up some data structure in the When step def like
the tables you showed last week, store it in a variable, and then assert on
it in the Then step def. (Unless, of course, that state is stored in the
system itself, in which case you might inspect it in the Then step def
without the shared state on the Cucumber side.)

Richard
Post by Mark Levison
​So this particular path appears to be an evolutionary dead end.
Cheers
Mark​
[image: headshot-square-300x300]
(877) 248-8277 | Twitter <https://twitter.com/mlevison> | LinkedIn
<http://ca.linkedin.com/in/marklevison> | Facebook
<https://www.facebook.com/agilepainrelief>
Certified ScrumMaster Training: Vancouver
<http://agilepainrelief.com/courses/vancouver> | Edmonton
<http://agilepainrelief.com/courses/edmonton> | Ottawa
<http://agilepainrelief.com/courses/ottawa> | Montreal
<http://agilepainrelief.com/courses/montreal> | Toronto
<http://agilepainrelief.com/courses/toronto>
Certified Product Owner & Private Training also available ~ Our Training
Schedule
<http://agilepainrelief.com/courses/certified-scrum-agile-training>
Agile Pain Relief Consulting <http://agilepainrelief.com/> | Notes from a
Tool User <http://agilepainrelief.com/notesfromatooluser>
Proud Sponsor of Agile Tour Gatineau Ottawa <http://goagiletour.ca/> and Agile
Coach Camp Canada <http://agilecoachcampcanada.wordpress.com/>
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Seb Rose
2015-01-20 17:30:46 UTC
Permalink
Post by Mark Levison
Just for fun I'm going to document what I learned in the past 60
minutes of coffee and code.
*Feature*: Teams Degrade if nothing done
*Scenario*: Capacity degrades each round if no action is taken
*When*the team only focuses on delivering stories
*Then*capacity decreases by 4 each round # The support code is
responsible for looping & checking
- The pain doesn't take effect until the 2nd round - its intended to
simulate the fact that we can get away with a bad habits for a few
weeks/sprints/iterations before our mistakes start to burn us
- Not allowing the team's capacity to go below zero led to special
case code in the tests
@Then("^capacity decreases by (\\d+) each round # The support code is
responsible for looping & checking$")
*public* void
capacity_decreases_by_each_round_The_support_code_is_responsible_for_looping_checking(
int capacityReduction) *throws* Throwable { // First Round no
effect teams.executeAction(ActionType.NoImprovement); *while*
(teams.getCapacity() > ) { int expectedCapacity = *Math*.max(,
teams.getCapacity() - capacityReduction);
teams.executeAction(ActionType.NoImprovement);
Assert.assertThat(teams.getCapacity(),
is(equalTo(expectedCapacity))); } }
Post by Mark Levison
So this particular path appears to be an evolutionary dead end.
Some observations:

1) Complex logic will need complex verifications - if you want to check
it, then the complexity will surface somewhere in your tests (maybe
in automation code, maybe in data sets)

2) The code you have written doesn't correspond to the language you use
in the step, because
- a) you state it doesn't decrease every round - only the 2nd and
subsequent rounds - but the step says it should
- b) you state it decreases by 4 each round, but then add that it can't
decrease below zero - so sometimes it won't decrease by 4.

There are a number of different business rules here, and you're
verifying all of them in a single scenario. You could write a
separate scenario for each of them, but some probably belong in lower
level tests.

For me it comes down to the question of "who is going to read the
scenarios?" If the answer includes "Non-technical stake holders", then
Cucumber is a good choice of tool. The amount of detail depends on what
will keep them interested and engaged. What do they care about?

Just my 2c

Seb
Post by Mark Levison
Cheers Mark
headshot-square-300x300 *Mark Levison* | 1 (877) 248-8277 | Twitter[1]
Vancouver[4] | Edmonton[5] | Ottawa[6] | Montreal[7] | Toronto[8]
Certified Product Owner & Private Training also available ~ Our
Training Schedule[9] Agile Pain Relief Consulting[10] | Notes from a
Tool User[11] Proud Sponsor of Agile Tour Gatineau Ottawa[12] and
Agile Coach Camp Canada[13]
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google
Groups "Cukes" group. To unsubscribe from this group and stop
receiving emails from it, send an email to
https://groups.google.com/d/optout.
--
The Cucumber for Java Book - Seb Rose, Matt Wynne & Aslak Hellesøy Now
available from the Pragmatic Press -
https://pragprog.com/book/srjcuc/the-cucumber-for-java-book



Links:

1. https://twitter.com/mlevison
2. http://ca.linkedin.com/in/marklevison
3. https://www.facebook.com/agilepainrelief
4. http://agilepainrelief.com/courses/vancouver
5. http://agilepainrelief.com/courses/edmonton
6. http://agilepainrelief.com/courses/ottawa
7. http://agilepainrelief.com/courses/montreal
8. http://agilepainrelief.com/courses/toronto
9. http://agilepainrelief.com/courses/certified-scrum-agile-training
10. http://agilepainrelief.com/
11. http://agilepainrelief.com/notesfromatooluser
12. http://goagiletour.ca/
13. http://agilecoachcampcanada.wordpress.com/
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Richard Lawrence
2015-01-20 17:49:30 UTC
Permalink
Post by Seb Rose
For me it comes down to the question of "who is going to read the
scenarios?" If the answer includes "Non-technical stake holders", then
Cucumber is a good choice of tool. The amount of detail depends on what
will keep them interested and engaged. What do they care about?
Just my 2c
Seb
Even on projects where the development team are the only ones who read the
Cucumber scenarios, I've still found a lot of value in using Cucumber and
working on the language to talk about the behavior the way a user would. It
creates a different level of empathy and a deeper understanding of the
domain than if we go straight to developer-facing tests.

Richard
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mark Levison
2015-01-20 17:51:48 UTC
Permalink
Richard describes what I'm trying to do here. As the Product Owner and
Developer of the game I'm attempting to force myself to be more clear so
that future readers don't have to think as hard to play the game.

Cheers
Mark
[image: headshot-square-300x300]
<http://www.flickr.com/photos/***@N00/9674877046/>*Mark Levison* | 1
(877) 248-8277 | Twitter <https://twitter.com/mlevison> | LinkedIn
<http://ca.linkedin.com/in/marklevison> | Facebook
<https://www.facebook.com/agilepainrelief>
Certified ScrumMaster Training: Vancouver
<http://agilepainrelief.com/courses/vancouver> | Edmonton
<http://agilepainrelief.com/courses/edmonton> | Ottawa
<http://agilepainrelief.com/courses/ottawa> | Montreal
<http://agilepainrelief.com/courses/montreal> | Toronto
<http://agilepainrelief.com/courses/toronto>
Certified Product Owner & Private Training also available ~ Our Training
Schedule <http://agilepainrelief.com/courses/certified-scrum-agile-training>
Agile Pain Relief Consulting <http://agilepainrelief.com/> | Notes from a
Tool User <http://agilepainrelief.com/notesfromatooluser>
Proud Sponsor of Agile Tour Gatineau Ottawa <http://goagiletour.ca/> and Agile
Coach Camp Canada <http://agilecoachcampcanada.wordpress.com/>
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Seb Rose
2015-01-20 18:33:51 UTC
Permalink
Richard describes what I'm trying to do here. As the Product Owner and Developer of the game I'm attempting to force myself to be more clear so that future readers don't have to think as hard to play the game.
Fair enough. Nevertheless, my observations about the complexity of the rules exercised by your single scenario still hold.

Seb
Cheers
Mark
Mark Levison | 1 (877) 248-8277 | Twitter | LinkedIn | Facebook
Certified ScrumMaster Training: Vancouver | Edmonton | Ottawa | Montreal | Toronto
Certified Product Owner & Private Training also available ~ Our Training Schedule
Agile Pain Relief Consulting | Notes from a Tool User
Proud Sponsor of Agile Tour Gatineau Ottawa and Agile Coach Camp Canada
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
For more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mark Levison
2015-01-20 18:35:56 UTC
Permalink
Oh I agree and after my workout I'm taking another crack at expressing this
more clearly. I sincerely appreciate the help.

Cheers
Mark
Post by Mark Levison
Richard describes what I'm trying to do here. As the Product Owner and
Developer of the game I'm attempting to force myself to be more clear so
that future readers don't have to think as hard to play the game.
Fair enough. Nevertheless, my observations about the complexity of the
rules exercised by your single scenario still hold.
Seb
Cheers
Mark
[image: headshot-square-300x300]
(877) 248-8277 | Twitter <https://twitter.com/mlevison> | LinkedIn
<http://ca.linkedin.com/in/marklevison> | Facebook
<https://www.facebook.com/agilepainrelief>
Certified ScrumMaster Training: Vancouver
<http://agilepainrelief.com/courses/vancouver> | Edmonton
<http://agilepainrelief.com/courses/edmonton> | Ottawa
<http://agilepainrelief.com/courses/ottawa> | Montreal
<http://agilepainrelief.com/courses/montreal> | Toronto
<http://agilepainrelief.com/courses/toronto>
Certified Product Owner & Private Training also available ~ Our Training Schedule
<http://agilepainrelief.com/courses/certified-scrum-agile-training>
Agile Pain Relief Consulting <http://agilepainrelief.com/> | Notes from a
Tool User <http://agilepainrelief.com/notesfromatooluser>
Proud Sponsor of Agile Tour Gatineau Ottawa <http://goagiletour.ca/> and Agile
Coach Camp Canada <http://agilecoachcampcanada.wordpress.com/>
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
[image: headshot-square-300x300]
<http://www.flickr.com/photos/***@N00/9674877046/>*Mark Levison* | 1
(877) 248-8277 | Twitter <https://twitter.com/mlevison> | LinkedIn
<http://ca.linkedin.com/in/marklevison> | Facebook
<https://www.facebook.com/agilepainrelief>
Certified ScrumMaster Training: Vancouver
<http://agilepainrelief.com/courses/vancouver> | Edmonton
<http://agilepainrelief.com/courses/edmonton> | Ottawa
<http://agilepainrelief.com/courses/ottawa> | Montreal
<http://agilepainrelief.com/courses/montreal> | Toronto
<http://agilepainrelief.com/courses/toronto>
Certified Product Owner & Private Training also available ~ Our Training
Schedule <http://agilepainrelief.com/courses/certified-scrum-agile-training>
Agile Pain Relief Consulting <http://agilepainrelief.com/> | Notes from a
Tool User <http://agilepainrelief.com/notesfromatooluser>
Proud Sponsor of Agile Tour Gatineau Ottawa <http://goagiletour.ca/> and Agile
Coach Camp Canada <http://agilecoachcampcanada.wordpress.com/>
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Andrew Premdas
2015-01-21 03:42:59 UTC
Permalink
On 20 January 2015 at 17:49, Richard Lawrence <
Post by Richard Lawrence
Post by Seb Rose
For me it comes down to the question of "who is going to read the
scenarios?" If the answer includes "Non-technical stake holders", then
Cucumber is a good choice of tool. The amount of detail depends on what
will keep them interested and engaged. What do they care about?
Just my 2c
Seb
Even on projects where the development team are the only ones who read the
Cucumber scenarios, I've still found a lot of value in using Cucumber and
working on the language to talk about the behavior the way a user would. It
creates a different level of empathy and a deeper understanding of the
domain than if we go straight to developer-facing tests.
Richard
+1000
Post by Richard Lawrence
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
------------------------
Andrew Premdas
blog.andrew.premdas.org
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Andrew Premdas
2015-01-21 04:26:12 UTC
Permalink
One of the problems I think your having with this stuff is that you are so
focused on 'how' the game works, that you can't describe its behaviour,
i.e. 'what' and 'why'.

Something that might be helpful in dealing with this is to analyze the
existing scenarios for consistency. (
http://pages.andrew.premdas.org/2011/11/18/consistency-in-features.html).
In this case if we start at the bottom and look upwards, i.e. from steps (G
W T) to Scenario to Feature, we can get some questions whose answers should
bring greater clarity


*Feature*: Teams Degrade if nothing done

*Scenario*: Capacity degrades each round if no action is taken

*When* the team only focuses on delivering stories

*Then* capacity decreases by 4 each round # The support code is
responsible for looping & checking


So starting with Then

Why 4, why not 2, 3, 27. Why is this decrease linear? How can this
decrease keep on going? Why degrade in the scenario but decrease in the
then?

- There is nothing above that gives any indication of this quantity,
so why include it.

Why do we need the comment? Stuff about looping and checking is the
'how', probably shouldn't be here


On to the When. It says 'the team only focuses on delivering stories' but
the scenario says 'Capacity degrades each round if no action is taken'.

Why are these so different?

If a team takes no action, surely they aren't doing anything. Do we
need an explanation/refinement of what 'no action' is

Would the scenario be better if we just replaced its text with the When
text e.g.

*Scenario*: Team focuses on only delivering stories

*When* the team only focuses on delivering stories

*Then* the teams capacity decrease

If the above isn't enough, whats the minimal amount we can add to
make it useful.


Looking up from the scenario:

The scenario says capacity degrades, the feature says teams degrade, Whats
the difference?

Why the difference between 'nothing done' and 'no action taken'?

etc. etc.


All of this might seem like nit-picking and pedentry; however this
critical/forensic analysis of the language we are using and its consistent
application, is the key to getting features that can actually be usefully
read. And to be honest if your features can't be read, how likely is it
that they can be implemented?


HTH


Andrew
Post by Mark Levison
Just for fun I'm going to document what I learned in the past 60 minutes
of coffee and code.
*Feature*: Teams Degrade if nothing done
*Scenario*: Capacity degrades each round if no action is taken
*When* the team only focuses on delivering stories
*Then* capacity decreases by 4 each round # The support code is
responsible for looping & checking
- The pain doesn't take effect until the 2nd round - its intended to
simulate the fact that we can get away with a bad habits for a few
weeks/sprints/iterations before our mistakes start to burn us
- Not allowing the team's capacity to go below zero led to special case
code in the tests
@Then("^capacity decreases by (\\d+) each round # The support code is responsible for looping & checking$")
public void capacity_decreases_by_each_round_The_support_code_is_responsible_for_looping_checking(
int capacityReduction) throws Throwable {
// First Round no effect
teams.executeAction(ActionType.NoImprovement);
while (teams.getCapacity() > 0) {
int expectedCapacity = Math.max(0, teams.getCapacity()
- capacityReduction);
teams.executeAction(ActionType.NoImprovement);
Assert.assertThat(teams.getCapacity(),
is(equalTo(expectedCapacity)));
}
}
​So this particular path appears to be an evolutionary dead end.
Cheers
Mark​
[image: headshot-square-300x300]
(877) 248-8277 | Twitter <https://twitter.com/mlevison> | LinkedIn
<http://ca.linkedin.com/in/marklevison> | Facebook
<https://www.facebook.com/agilepainrelief>
Certified ScrumMaster Training: Vancouver
<http://agilepainrelief.com/courses/vancouver> | Edmonton
<http://agilepainrelief.com/courses/edmonton> | Ottawa
<http://agilepainrelief.com/courses/ottawa> | Montreal
<http://agilepainrelief.com/courses/montreal> | Toronto
<http://agilepainrelief.com/courses/toronto>
Certified Product Owner & Private Training also available ~ Our Training
Schedule
<http://agilepainrelief.com/courses/certified-scrum-agile-training>
Agile Pain Relief Consulting <http://agilepainrelief.com/> | Notes from a
Tool User <http://agilepainrelief.com/notesfromatooluser>
Proud Sponsor of Agile Tour Gatineau Ottawa <http://goagiletour.ca/> and Agile
Coach Camp Canada <http://agilecoachcampcanada.wordpress.com/>
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
------------------------
Andrew Premdas
blog.andrew.premdas.org
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...