Re: [Cucumber] [JS] Scenario Outline, Conditional Examples

1,344 views
Skip to first unread message

aslak hellesoy

unread,
May 8, 2013, 8:02:51 AM5/8/13
to Cucumber Users



On Wed, May 8, 2013 at 5:06 AM, Marc Fallows <ma...@marcfallows.com> wrote:
I have the following scenario outline:

Scenario Outline: Pressing buttons
Given I push the <button> button
Then I should see the <page> page

Examples:
| BUTTON | PAGE   |
| RED    | Login  |
| BLUE   | Home   |
| YELLOW | Logout |
| INFO   | FAQ    |

I run this test on different devices. Some of these devices don't have support for certain buttons (may only have a red, blue and yellow button... but no info button). The real outline contains many more rows and columns in the example table.

Is there a way to filter out certain examples based on functional criteria?

You *should* be able to do this:

Scenario Outline: Pressing buttons
  Given I push the <button> button
  Then I should see the <page> page

  Examples:
    |  BUTTON | PAGE   |
    |  RED    | Login  |
    |  BLUE   | Home   |
    |  YELLOW | Logout |

  @big-screen
  Examples:
    | BUTTON | PAGE |
    | INFO   | FAQ  |

Then you can run with --tags ~@big-screen when testing agains devices that don't have a big screen (and therefore don't display the INFO button).

I said *should* because Cucumber-Ruby and Cucumber-JVM lets you do this. I haven't verified that it works on Cucumber-JS.

Aslak

I have access to the key map that is supported on the device running the tests so ideally I would filter out the examples that do not apply before the scenarios are built. Is that possible? It did not seem possible to access the example table at any point in the process.

I look forward to any thoughts or recommendations.

Cheers,
Marc

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

George Dinwiddie

unread,
May 8, 2013, 9:13:55 AM5/8/13
to cu...@googlegroups.com
Marc,
Another idea is to shortcut within the scenario. Since you know which
devices have which buttons, in the "Given I push the <button> button"
step definition throw a Pending exception if the device doesn't support
that button.

- George


--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.org
----------------------------------------------------------------------

Andrew Premdas

unread,
May 8, 2013, 10:07:51 AM5/8/13
to cu...@googlegroups.com
On 8 May 2013, at 11:06, Marc Fallows <ma...@marcfallows.com> wrote:
I have the following scenario outline:

Scenario Outline: Pressing buttons
Given I push the <button> button
Then I should see the <page> page

Examples:
| BUTTON | PAGE   |
| RED    | Login  |
| BLUE   | Home   |
| YELLOW | Logout |
| INFO   | FAQ    |

I run this test on different devices. Some of these devices don't have support for certain buttons (may only have a red, blue and yellow button... but no info button). The real outline contains many more rows and columns in the example table.

Is there a way to filter out certain examples based on functional criteria? I have access to the key map that is supported on the device running the tests so ideally I would filter out the examples that do not apply before the scenarios are built. Is that possible? It did not seem possible to access the example table at any point in the process.

I look forward to any thoughts or recommendations.

Cheers,
Marc

--


If you pushed the how down into the step definitions, then maybe you get to you key map there. Using this approach you could write a simple scenario for each device

When I test the buttons on foo
Then I should see that the buttons take me to the correct pages

With this approach you can remove the clever stuff you are using to run a feature on each device; and the example group table, and get better output when something goes wrong. 


Marc Fallows

unread,
May 8, 2013, 11:20:36 AM5/8/13
to cu...@googlegroups.com
Thanks for the suggestion George. How do you throw a pending exception in CucumberJS? 

Also, is there a skip exception or similar? It's not that the test is pending, but rather that the test does not apply in this case.

Ideally I would prefer to avoid a tag based approach as we are running the same set of tests across all devices. The supported buttons are mapped in javascript so it would be good if the definitions could handle omitting certain tests.

The same goes for a generic scenario. I want to be able to read through the scenario and know what actions I expect to happen. Someone who is not a developer could then modify the expected behavior of a button in the scenarios without needing to change the definitions.


George Dinwiddie

unread,
May 8, 2013, 1:38:02 PM5/8/13
to cu...@googlegroups.com
Marc,

On 5/8/13 11:20 AM, Marc Fallows wrote:
> On Wednesday, May 8, 2013 2:13:55 PM UTC+1, George Dinwiddie wrote:
>
> Marc,
>
> On 5/8/13 8:02 AM, aslak hellesoy wrote:
> >
> >
> >
> > On Wed, May 8, 2013 at 5:06 AM, Marc Fallows
> <ma...@marcfallows.com <javascript:>
I've not used CucumberJS, but looking at
https://github.com/cucumber/cucumber-js/blob/master/features/step_definitions/cucumber_steps.js
it appears that "callback.pending('Button not implemented.')" might work.

- George

>
> Also, is there a skip exception or similar? It's not that the test is
> pending, but rather that the test does not apply in this case.
>
> Ideally I would prefer to avoid a tag based approach as we are running
> the same set of tests across all devices. The supported buttons are
> mapped in javascript so it would be good if the definitions could handle
> omitting certain tests.
>
> The same goes for a generic scenario. I want to be able to read through
> the scenario and know what actions I expect to happen. Someone who is
> not a developer could then modify the expected behavior of a button in
> the scenarios without needing to change the definitions.
>
>
> --
> -- Rules --
>
> 1) Please prefix the subject with [Ruby], [JVM] or [JS].
> 2) Please use interleaved answers
> http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
> 3) If you have a question, don't reply to an existing message. Start a
> new topic instead.
>
> You received this message because you are subscribed to the Google
> Groups Cukes group. To post to this group, send email to
> cu...@googlegroups.com. To unsubscribe from this group, send email to
> cukes+un...@googlegroups.com. For more options, visit this group
> at https://groups.google.com/d/forum/cukes?hl=en
> ---
> 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+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Matt Wynne

unread,
May 9, 2013, 5:35:42 AM5/9/13
to cu...@googlegroups.com

Julien Biezemans

unread,
May 9, 2013, 9:40:54 AM5/9/13
to cu...@googlegroups.com
That's correct. 
 
I'm confused. Cucumber-JS doesn't support Scenario Outlines yet:



That's also correct. Scenario outlines support has been voluntarily delayed for months (yeah, evil me) but it is now being implemented. It'll be available in the next couple of weeks or do. 

Back to the original topic: pushing the how down, as suggested by Andrew seems to be the cleanest approach, IMO. 

Filtering through tags is also neat and completely supported by cucumber.js. 

Both ways could even be mixed together so that relevant simple scenarios (in opposition to outline examples) could be run depending on the current device.

Peter Fitzgibbons

unread,
Nov 7, 2013, 4:53:48 PM11/7/13
to cu...@googlegroups.com
HI Cukes, Aslak,

I've been trying this, with the following :

  Scenario Outline: Simple Test
    When I am on the "<property>" 
    Then I should see "Welcome"

  @LA
  Examples:
    | property | user       |
    | LATimes  | TribTester |

  @CT
  Examples:
    | property       | user       |
    | ChicagoTribune | TribTester |

  @SS
  Examples:
    | property    | user       |
    | SunSentinel | TribTester |

  @OS
  Examples:
    | property        | user       |
    | OrlandoSentinel | TribTester |

When I run with this CLI, all Examples are still run.
cucumber -t ~@LA -t ~@SS

Could you give me any ideas on what I'm doing wrong?

Thanks and Kindest Regards,

Peter Fitzgibbons
(847) 859-9550
Email: peter.fi...@gmail.com
IM GTalk: peter.fitzgibbons
IM AOL: peter.fi...@gmail.com


Aslak Hellesøy

unread,
Nov 7, 2013, 6:13:19 PM11/7/13
to cu...@googlegroups.com

On Thursday, 7 November 2013 at 21:53, Peter Fitzgibbons wrote:

HI Cukes, Aslak,

I've been trying this, with the following :

  Scenario Outline: Simple Test
    When I am on the "<property>" 
    Then I should see "Welcome"

  @LA
  Examples:
    | property | user       |
    | LATimes  | TribTester |

  @CT
  Examples:
    | property       | user       |
    | ChicagoTribune | TribTester |

  @SS
  Examples:
    | property    | user       |
    | SunSentinel | TribTester |

  @OS
  Examples:
    | property        | user       |
    | OrlandoSentinel | TribTester |

When I run with this CLI, all Examples are still run.
cucumber -t ~@LA -t ~@SS

This is a logical and of two negations. You want a logical or:

-t ~@LA,~@SS 

Aslak
Could you give me any ideas on what I'm doing wrong?

Thanks and Kindest Regards,

Peter Fitzgibbons
(847) 859-9550
Email: peter.fi...@gmail.com
IM GTalk: peter.fitzgibbons
IM AOL: peter.fi...@gmail.com


Peter Fitzgibbons

unread,
Nov 8, 2013, 7:32:53 AM11/8/13
to cu...@googlegroups.com
Ahah!  That worked.

I also discovered that running a feature file with line-number selectors ( features/web_test.feature:8 ) seems to circumvent tag filtering.  Does that agree with what you know?

Thanks for the help.  This will be a huge benefit to my company's testing workflow.

Kindest Regards,

Peter Fitzgibbons
(847) 859-9550
Email: peter.fi...@gmail.com
IM GTalk: peter.fitzgibbons
IM AOL: peter.fi...@gmail.com


Aslak Hellesøy

unread,
Nov 8, 2013, 7:35:58 AM11/8/13
to cu...@googlegroups.com

On Friday, 8 November 2013 at 12:32, Peter Fitzgibbons wrote:

Ahah!  That worked.

I also discovered that running a feature file with line-number selectors ( features/web_test.feature:8 ) seems to circumvent tag filtering.  Does that agree with what you know?

Yes, filter types cannot be mixed. Use one of --tags, --name or line
Thanks for the help.  This will be a huge benefit to my company's testing workflow.

Awesome! 

Dave Wong

unread,
Jan 20, 2015, 4:54:41 AM1/20/15
to cu...@googlegroups.com
Hi,

Bit late to the party but when I run my cucumberjs scenarios I get:

Warning: Scenario outlines are not supported yet. See https://github.com/cucumber/cucumber-js/issues/10 Use --force to continue.

Has this been implemented?  I'm running 0.4.7

Thanks.



- George

cukes+unsubscribe@googlegroups.com. For more options, visit this group

at https://groups.google.com/d/forum/cukes?hl=en
---
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

--
----------------------------------------------------------------------
 * George Dinwiddie *                      http://blog.gdinwiddie.com
 Software Development                    http://www.idiacomputing.com
 Consultant and Coach                    http://www.agilemaryland.org
----------------------------------------------------------------------

--
-- Rules --

1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.

You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en

--- 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+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en

---
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+unsubscribe@googlegroups.com.

Julien Biezemans

unread,
Jan 20, 2015, 9:05:54 AM1/20/15
to cu...@googlegroups.com
On Tue Jan 20 2015 at 11:43:57 AM Dave Wong <wongc...@gmail.com> wrote:
Hi,

Bit late to the party but when I run my cucumberjs scenarios I get:

Warning: Scenario outlines are not supported yet. See https://github.com/cucumber/cucumber-js/issues/10 Use --force to continue.

Has this been implemented?  I'm running 0.4.7


Yes scenario outlines have been supported for quite a while now. I don't understand where that warning comes from nor what is that --force flag.

Are you sure you're running cucumber.js 0.4.7?



---
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages