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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With