Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JBehave maintain data across steps Given/When/Then during a Scenario

Tags:

bdd

jbehave

I have been trying JBehave for sometime and I need to figure out if there exists a way to maintain data across steps during the run of one particular scenario ? I mean is it possible to maintain the state/data during a scenario across the Given/When/Then with out using any state variable under the Step Class.

like image 617
Bhuvnesh Pratap Avatar asked Feb 22 '12 06:02

Bhuvnesh Pratap


1 Answers

Yes, you can pass an object that maintains the shared state to the different steps.

The Noughts And Crosses example in jbehave core demonstrates this. There's some share state between stories that is maintained in the class WindowControl.

See that the class NoughtsAndCrossesStory that sets up the environment injects an instance of WindowControl to all the steps.

like image 139
Augusto Avatar answered Oct 15 '22 11:10

Augusto