Reputation: 666
Given a stock threshold of 10.0
When stock threshold is set to 10.0
Then threshold result should be 10.0
In above steps, instead of the constant value 10.0, I'd like to use a predefined variable. Like,
Given a stock threshold of <thresholdValue>
When stock threshold is set to <thresholdValue>
Then threshold result should be <thresholdValue>
This predefined variable can be a global variable for all stories. And the value can be initialized in step classes, or story file itself. Can this kind of implementation can be done in JBehave.
Upvotes: 1
Views: 404
Reputation: 18783
If the threshold value is the same in each story then I wouldn't hard code it into the steps. If there is significance to the value 10.0
then I would give it a name that makes sense to the business:
Given an average stock threshold
Given a nominal stock threshold
Or just forgo the value all together and simplify each step:
Given a stock threshold
When the stock threshold is set
Then the stock threshold should be met
If having a hard coded value for each step is absolutely necessary, either copy and paste the value and just live with it, or use different values in each scenario. Often times a variance in test data is better than using the same test data over and over.
Basically if 10.0
does not have any business significance, omit the value and let the value be hard coded in the step definition, or copy and paste the value. Don't waste a lot of thought on this.
Upvotes: 0