Skip to main content

Injecting parameters in story file?

  4 posts   Feedicon  
Replies: 3 - Last Post: May 22, 2013 00:38
by: MichaelT_
showing 1 - 4 of 4
Posted: April 11, 2013 04:48 by MichaelT_

I'm currently using Thucydides + JBehave v0.9.110 and was just trying to get parameterised stories working (I was working off the example given on the JBehave site).

I had something similar to (taken from JBehave site) in my .story file:
Given a stock of <symbol> and a <threshold>
When the stock is traded at <price>
Then the alert status should be <status>


@Given("a stock of <symbol> and a <threshold>")
public void aStock(@Named("symbol") String symbol, @Named("threshold") double threshold) {
// ...

However it seems as though the <symbol> and <threshold> strings where being passed as they are defined (with less than / greater than included i.e <symbol>).

My question is, should this be possible? Or is there another way to go about this? I had a look at the reference doco but couldn't see any indication on there.

Thanks in advance,

Posted: April 11, 2013 06:02 by MichaelT_
Note "" equates to "DefinitionSteps".
Posted: April 11, 2013 20:26 by jkusa
The Example Table is stored internally as a List of <String,String>Map:

So you will not be able to pass a double to your function. Your best bet is to pass the number as a string and parse it with Double.parseDouble(threshold) .

Posted: May 22, 2013 00:38 by MichaelT_
Thanks jkusa, that seemed to do the trick.
Replies: 3 - Last Post: May 22, 2013 00:38
by: MichaelT_
Please Confirm