Discussion:
[Cucumber] Scenario splitting
(too old to reply)
Christian Baumann
2018-06-15 08:08:47 UTC
Permalink
Raw Message
Hi all,

I have a page, where the user selects passengers (pax) and a hotel.
When both is selected, the next button on the page is enabled, and when the
user clicks it, he will be forwarded to the next page.
The back button should be enabled all the time.

I want to test for the next button, if itÂŽs enabled and forwards only when
pax and hotel are selected, I know that these are two different concerns,
so I would need two scenarios, in order to avoid something like "When...
Then... When... Then...".
But on the other I hand, I also want to follow DRY (donÂŽt repeat yourself).

This is what I came up with, any ideas on how to solve this in an elegant
way?

*Scenario Outline:* Button status and navigation
*Given* that IÂŽm on the "hotel" page
*When* I have <pax_selection> selected passengers
*And* I have <hotel_selection> selected a hotel
*Then* the <navigation_button> is <status>
*When* I click <navigation_button>
*Then* IÂŽm being forwarded to the "<page>" page

*Examples:*
| pax_selection | hotel_selection | navigation_button | status |
page |
| true | true | back | enabled |
Agency |
| true | false | back | enabled |
Agency |
| false | true | back | enabled |
Agency |
| false | false | back | enabled |
Agency |
| true | true | forward | enabled |
Dates |
| true | false | forward | disabled |
Hotel |
| false | true | forward | disabled |
Hotel |
| false | false | forward | disabled |
Hotel |

Many thanks in advance,
Christian
--
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.
George Dinwiddie
2018-06-16 03:36:07 UTC
Permalink
Raw Message
Hi, Christian,
Post by Christian Baumann
Hi all,
I have a page, where the user selects passengers (pax) and a hotel.
When both is selected, the next button on the page is enabled, and when
the user clicks it, he will be forwarded to the next page.
The back button should be enabled all the time.
I want to test for the next button, if it´s enabled and forwards only
when pax and hotel are selected, I know that these are two different
concerns, so I would need two scenarios, in order to avoid something
like "When... Then... When... Then...".
But on the other I hand, I also want to follow DRY (don´t repeat yourself).
This is what I came up with, any ideas on how to solve this in an
elegant way?
*Scenario Outline:* Button status and navigation
*Given* that I´m on the "hotel" page
*When* I have <pax_selection> selected passengers
*And* I have <hotel_selection> selected a hotel
*Then* the <navigation_button> is <status>
*When* I click <navigation_button>
*Then* I´m being forwarded to the "<page>" page
*Examples:*
    | pax_selection | hotel_selection | navigation_button | status   |
page   |
    | true          | true            | back              | enabled  |
Agency |
    | true          | false           | back              | enabled  |
Agency |
    | false         | true            | back              | enabled  |
Agency |
    | false         | false           | back              | enabled  |
Agency |
    | true          | true            | forward           | enabled  |
Dates  |
    | true          | false           | forward           | disabled |
Hotel  |
    | false         | true            | forward           | disabled |
Hotel  |
    | false         | false           | forward           | disabled |
Hotel  |
I generally don't recommend scenarios for testing the representation on
the page or the page order of the workflow. That might easily change.
There's some underlying behavior that won't change (much), because
that's why the system is being created. The minutia of the GUI will get
tested in passing while testing the important behavior.

As I see it, you've really only got three cases.
1. That you can go backwards.
2. That when the passenger and hotel are selected, you can go forwards.
3. That when either the passenger or hotel is not selected, you
cannot go forward.

If you are afraid things will break and want to test all the
permutations in your test suite, I would write unit tests for that.

My advice is to pop up a level of abstraction, and test that.

- George
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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
2018-06-16 10:48:19 UTC
Permalink
Raw Message
Christian,

Put yourself in my position, looking at this scenario and think about

1. How long is it going to take me to work out what is happening in this
scenario
2. How certain can I be that this scenario is correct e.g. can I be sure
that the row true, true, forward, enabled should have Dates as its page
3. How well this communicates why each of these rules are being applied

Then re-evaluate the value of DRY in this situation.

There is a more detailed example to consider in an old blog post of mine
http://pages.andrew.premdas.org/2011/06/27/composable-features-and-tables.html

The thing about scenarios like the one you have created is that they
combine, obfuscate and compress lots of interesting little rules into a big
complex blob. This prevents you from reading, understanding and thinking
about each of these little rules, and vastly increases the cost of changing
those rules. I would suggest following these two rules of thumb to simplify
your Gherkin.

1. Don't write outlines. If you are tempted to STOP and rethink.
2. Avoid putting HOW you do things in scenarios - things like clicking
buttons, filling fields even landing on pages belong further down the stack
3. Actively try and find names for things. In your example you are look as
though you are doing some sort of Hotel Reservation so talk about that

Cucumber is completely the wrong tool for writing your scenario you have 2
postive choices going forward

1. Use a different tool for these sorts of tests
2. Change how you use cucumber to write more effective scenarios

Good luck

Andrew
Post by George Dinwiddie
Hi, Christian,
Post by Christian Baumann
Hi all,
I have a page, where the user selects passengers (pax) and a hotel.
When both is selected, the next button on the page is enabled, and when
the user clicks it, he will be forwarded to the next page.
The back button should be enabled all the time.
I want to test for the next button, if itÂŽs enabled and forwards only
when pax and hotel are selected, I know that these are two different
concerns, so I would need two scenarios, in order to avoid something like
"When... Then... When... Then...".
But on the other I hand, I also want to follow DRY (donÂŽt repeat yourself).
This is what I came up with, any ideas on how to solve this in an elegant
way?
*Scenario Outline:* Button status and navigation
*Given* that IÂŽm on the "hotel" page
*When* I have <pax_selection> selected passengers
*And* I have <hotel_selection> selected a hotel
*Then* the <navigation_button> is <status>
*When* I click <navigation_button>
*Then* IÂŽm being forwarded to the "<page>" page
*Examples:*
| pax_selection | hotel_selection | navigation_button | status |
page |
| true | true | back | enabled |
Agency |
| true | false | back | enabled |
Agency |
| false | true | back | enabled |
Agency |
| false | false | back | enabled |
Agency |
| true | true | forward | enabled |
Dates |
| true | false | forward | disabled |
Hotel |
| false | true | forward | disabled |
Hotel |
| false | false | forward | disabled |
Hotel |
I generally don't recommend scenarios for testing the representation on
the page or the page order of the workflow. That might easily change.
There's some underlying behavior that won't change (much), because that's
why the system is being created. The minutia of the GUI will get tested in
passing while testing the important behavior.
As I see it, you've really only got three cases.
1. That you can go backwards.
2. That when the passenger and hotel are selected, you can go forwards.
3. That when either the passenger or hotel is not selected, you cannot
go forward.
If you are afraid things will break and want to test all the permutations
in your test suite, I would write unit tests for that.
My advice is to pop up a level of abstraction, and test that.
- George
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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
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.
Christian Baumann
2018-06-18 11:48:20 UTC
Permalink
Raw Message
Hi George,

My advice is to pop up a level of abstraction, and test that.

Many thanks for that, I think I got lost a bit when trying to figure it
out...

As I see it, you've really only got three cases.

ThatÂŽs absolutely true, so I will concentrate on those.

Best,
Christian

Am Sa., 16. Juni 2018 um 05:36 Uhr schrieb George Dinwiddie <
Post by George Dinwiddie
Hi, Christian,
Post by Christian Baumann
Hi all,
I have a page, where the user selects passengers (pax) and a hotel.
When both is selected, the next button on the page is enabled, and when
the user clicks it, he will be forwarded to the next page.
The back button should be enabled all the time.
I want to test for the next button, if itÂŽs enabled and forwards only
when pax and hotel are selected, I know that these are two different
concerns, so I would need two scenarios, in order to avoid something
like "When... Then... When... Then...".
But on the other I hand, I also want to follow DRY (donÂŽt repeat
yourself).
Post by Christian Baumann
This is what I came up with, any ideas on how to solve this in an
elegant way?
*Scenario Outline:* Button status and navigation
*Given* that IÂŽm on the "hotel" page
*When* I have <pax_selection> selected passengers
*And* I have <hotel_selection> selected a hotel
*Then* the <navigation_button> is <status>
*When* I click <navigation_button>
*Then* IÂŽm being forwarded to the "<page>" page
*Examples:*
| pax_selection | hotel_selection | navigation_button | status |
page |
| true | true | back | enabled |
Agency |
| true | false | back | enabled |
Agency |
| false | true | back | enabled |
Agency |
| false | false | back | enabled |
Agency |
| true | true | forward | enabled |
Dates |
| true | false | forward | disabled |
Hotel |
| false | true | forward | disabled |
Hotel |
| false | false | forward | disabled |
Hotel |
I generally don't recommend scenarios for testing the representation on
the page or the page order of the workflow. That might easily change.
There's some underlying behavior that won't change (much), because
that's why the system is being created. The minutia of the GUI will get
tested in passing while testing the important behavior.
As I see it, you've really only got three cases.
1. That you can go backwards.
2. That when the passenger and hotel are selected, you can go forwards.
3. That when either the passenger or hotel is not selected, you
cannot go forward.
If you are afraid things will break and want to test all the
permutations in your test suite, I would write unit tests for that.
My advice is to pop up a level of abstraction, and test that.
- George
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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
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.
Loading...