[Cucumber] Sharing examples between Scenario Outlines

944 views
Skip to first unread message

Isaac Devine

unread,
May 26, 2009, 4:07:26 AM5/26/09
to Cukes
Hi all,

I'm writing a feature for importing data into our application. I have
a list of example data that is spread in different places in the data
format I am importing. Also this list of data is quite verbose and
large. I have different scenario outlines to catch different cases of
this data and want to share a single examples: definition between
them.

ie.

Feature: Import data from legacy third party format
In order for our customers to have up to date information
They want to be to import existing information


Scenario Outline: Import a file into a blank database
Given I have nothing
When I import file 'features/support/blahh.extension'
Then I should have Item '<ItemId>' with '<Description>'

Scenario Outline: Import a file into an existing database
Given I have item '<Code>' created with description 'dummy'
When I import file 'features/support/blahh.extension'

Examples:
|Code|Description|
|XXXX|Really Long description that goes over a bunch of lines|


Additionally what is also confusing is that the first Scenario Outline
doesn't fail, even though it has no examples, is this desired
behaviour?

Am I doing anything wrong? Is there an existing way to accomplish
this?

If not, where should I start looking to add it?

I can't find any feature definitions for scenario outlines in
http://github.com/aslakhellesoy/cucumber/tree/cb17d9de1ea04e43ecc30f96ba53a68e41b93395/features

I'm using:
cucumber 0.3.7
rspec 1.2.6,
webrat 0.4.4
rails 2.3.2
ubuntu 09.04

Cheers,
Isaac

Matt Wynne

unread,
May 27, 2009, 9:07:04 AM5/27/09
to cu...@googlegroups.com
Yes, currently that's what it's supposed to do, though probably only
because nobody has yet noticed (as you have) that it's a bit silly.
What would you have expected it to do? Would you mind describing the
desired behaviour in a lighthouse ticket?

> Am I doing anything wrong? Is there an existing way to accomplish
> this?

The way I've done this before, and it's a bit of a hack, is to roll up
the steps in each of those different scenario outlines into single
steps, then put those in the table as well. So my feature pretty much
ends up looking like this:

Given I have <What I have> and I import the file '<File>'
When I should have Item '<Item>' with '<Description>'

> If not, where should I start looking to add it?

The first step is to add a lighthouse ticket, and we can start some
discussion about how we might support this use case. It's certainly
something that's cropped up for me a couple of times - the ability to
run different scenario outlines through the same set of examples.

> I can't find any feature definitions for scenario outlines in
> http://github.com/aslakhellesoy/cucumber/tree/cb17d9de1ea04e43ecc30f96ba53a68e41b93395/features

Some of the features are tested using the 'self-test' example
application.

http://github.com/aslakhellesoy/cucumber/blob/867e14f0f3910cc8ac64c5f96c8c9c80e72f5ddc/examples/self_test/features/outline_sample.feature

> I'm using:
> cucumber 0.3.7
> rspec 1.2.6,
> webrat 0.4.4
> rails 2.3.2
> ubuntu 09.04
>
> Cheers,
> Isaac
> >

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com

Isaac Devine

unread,
May 27, 2009, 8:43:18 PM5/27/09
to Cukes
I've created ticket #347 (
http://rspec.lighthouseapp.com/projects/16211/tickets/347-scenario-outline-passes-with-no-examples
) for this bug.

>
> > Am I doing anything wrong? Is there an existing way to accomplish
> > this?
>
> The way I've done this before, and it's a bit of a hack, is to roll up  
> the steps in each of those different scenario outlines into single  
> steps, then put those in the table as well. So my feature pretty much  
> ends up looking like this:
>
> Given I have <What I have> and I import the file '<File>'
> When I should have Item '<Item>' with '<Description>'
>
> > If not, where should I start looking to add it?
>
> The first step is to add a lighthouse ticket, and we can start some  
> discussion about how we might support this use case. It's certainly  
> something that's cropped up for me a couple of times - the ability to  
> run different scenario outlines through the same set of examples.

I've added ticket #348 (
http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/348-run-different-scenario-outlines-through-the-same-set-of-examples
) for this, along with a more refined idea of how to share examples,
by refering to the example name.

>
> > I can't find any feature definitions for scenario outlines in
> >http://github.com/aslakhellesoy/cucumber/tree/cb17d9de1ea04e43ecc30f9...
>
> Some of the features are tested using the 'self-test' example  
> application.
>
> http://github.com/aslakhellesoy/cucumber/blob/867e14f0f3910cc8ac64c5f...

Cheers! Will start looking around and try to grok the code a bit more.
Reply all
Reply to author
Forward
0 new messages