JBehave provides a nice feature for parameterizing scenarios to allow
repeating tests.  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


I was hoping to trying to extend its use in combination with a Given Story.

To demonstrate by means of extending the documentation example:-

I want to extend it to support a  GivenStory that selects the current
StockExchange
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

When trying this I found that the 'GivenStory'  did not inherit the
parameterized variables.
The alternate was to use the anchor tag

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

but now the example parameters are not available to my parent story AND I
can only pass in one row to the given Story rather than repeating the test.

The documentation does make clear that this is a known restriction -  but I
thought I'd post to this forum to see if there is any recommendation on how
achieve the desired behaviour?

thanks
Dave

Reply via email to