Allow GivenStories to be parametrised by examples in a scenario context

Description

Introduction

JBehave supports parameterizing scenarios to allow repeating tests. e.g. As shown in the documentation:-

Given a stock of <symbol> and a <threshold> When the stock is traded at <price> Then the alert status should be <status> Examples: |symbol|threshold|price|status| |STK1|10.0|5.0|OFF| |STK1|10.0|11.0|ON

It would be desirable if this convention could be extended to be used in combination with a Given Story.
To demonstrate by means of an extension to the documentation example:-
Suppose there is a requirement to select a specific "Stock Exchange" before executing each of the tests above.
Rather than building this into the story, we might opt, for reuse purposes, to use a Given Story to first select the "Stock Exchange".

Now the first example would be 'Nasdaq' and the second 'FTSE'.

The hypothetical configuration might then be:-

GivenStories: acme/givenstories/SelectAStockExchange.story Given a stock of <symbol> and a <threshold> When the stock is traded at <price> Then the alert status should be <status> Examples: |stockExchange|symbol|threshold|price|status| |NASDAQ|STK1|10.0|5.0|OFF| |FTSE|STK1|10.0|11.0|ON

Current Behaviour

Unfortunately the example above will not work as desired
The 'GivenStory', SelectAStockExchange.story, does not inherit the parameterized variables as night be expected.
Nor does the obvious supporting feature, anchor tags, help because only a specific row number can be specified in the anchor tag.
e.g.

GivenStories: acme/givenstories/SelectAStockExchange.story{0}

Suggested Behaviour

The Given Story should be considered part of the be parametrised scenario context and inherit the parameters of the row currently being executed.

Referencing previous response from Mauro on the dev mail thread

"As I understand it, you'd like the GivenStories to be considered as part of the parametrised scenario context and be passed the row of parameters that is being processed as part of a parametrised scenario. I guess, we could make that the default behaviour, and any parameters passed to the given stories could be overridden by the execution of the given story"

Activity

Mauro Talevi
updated the Fix versionsMay 22, 2015 at 8:10 AM
3.6.2, 3.7
None
Mauro Talevi
updated the Fix versionsMay 22, 2015 at 8:10 AM
None
3.6.2
Mauro Talevi
created the IssueMarch 30, 2012 at 9:33 PM
Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created March 30, 2012 at 9:33 PM
Updated May 22, 2015 at 8:10 AM
Resolved April 10, 2012 at 7:08 AM

Flag notifications